C++ program to perform unique factorization of a Given Number

Nishu Kumari
Updated on 29-May-2025 19:24:54

207 Views

Here is a C++ Program to get all the unique factorization of a given integer such that addition of a partition results an integer. In this program, a positive integer n is given, and we shall generate all possible unique ways to represent n as sum of positive integers. Algorithm to Perform Unique Factorization Below is the algorithm to perform the unique factorization of a given number: Begin function displayAllUniqueParts(int m): 1) Set Index of last element k in a partition to 0 ... Read More

C++ Program to Find Minimum Value of any Algebraic Expression

Nishu Kumari
Updated on 29-May-2025 19:24:33

303 Views

The algebraic expression is a combination of numbers, variables (x or y), and arithmetic operators like +, -, *, and /. In this article, we'll write a C++ program to find the minimum value of an expression in the form (x1 + x2 + x3 + . . . + xa) * (y1 + y2 + . . . + yb) where a total of a+b integers are given. Our task is to split these integers into two groups, one with a numbers and the other with b numbers, and calculate the product of their sums. By trying ... Read More

C++ Program to Find Maximum Value of any Algebraic Expression

Nishu Kumari
Updated on 29-May-2025 19:24:10

300 Views

The algebraic expression is a combination of numbers, variables (x or y), and arithmetic operators like +, -, *, and /. In this article, we'll write a C++ program to find the maximum value of an expression in the form (x1 + x2 + x3 + . . . + xa) * (y1 + y2 + . . . + yb) where a total of a+b integers are given. Our task is to split these integers into two groups, one with a numbers and the other with b numbers, and calculate the product of their sums. By ... Read More

Convert String to Double in Java

Aishwarya Naglot
Updated on 29-May-2025 19:21:03

543 Views

In this article, we will learn to convert a string to a double in Java.  Problem Statement Given a string representing a decimal number, convert it into a double in Java. The input string is guaranteed to be a valid numeric representation. Input: String str = "23.6"; Output: 23  Converting String to Double in Java The following are the different approaches for converting a string to a double in Java - Using Double.parseDouble() Using Double.valueOf() Using String to Double Constructor Using DecimalFormat ... Read More

C++ Program to Check Whether a Graph is Strongly Connected or Not

Ravi Ranjan
Updated on 29-May-2025 19:19:15

428 Views

To check if a graph is strongly connected or not, we need to check if for any pair of vertices u and v in the directed graph, there exists a directed path from u to v and a directed path from v to u. In this article, we have a directed graph with five vertices and its respective adjacency matrix. Our task is to check if the given graph is strongly connected or not. Example of Strongly Connected Graph The graph displayed in the figure below is an example of a strongly connected graph. In the above graph, ... Read More

C++ Program to Generate a Graph for a Given Fixed Degree Sequence

Ravi Ranjan
Updated on 29-May-2025 19:18:23

343 Views

In this article, we will understand how to generate a graph for a given fixed-degree sequence. The degree of each node is given in the form of an array. The graph generated will be an undirected graph where the degree of each node will correspond to the given degree array. Example The following example generates a graph and adjacency matrix for the given degree sequence: Input: Degree Sequence: {3, 2, 3, 2} => Degree(Node a) = 3, Degree(Node b) = 2, Degree(Node c) = 3, Degree(Node d) = 2 ... Read More

C++ Program to Check Whether an Undirected Graph Contains a Eulerian Path

Ravi Ranjan
Updated on 29-May-2025 19:17:56

1K+ Views

The Euler path is a path using which we can visit every edge exactly once in a graph. The same vertex can be used for multiple times. The source and destination nodes in the Euler path are different. If the source and destination node become the same, then the Eulerian path is also an Eulerian cycle. In this article, our task is to check if there exists an Eulerian path in the given undirected graph. Example of Eulerian Path The figure below displays an undirected graph and its respective adjacency matrix. As we can see there exists an Eulerian ... Read More

How to pass an array by reference in C++

Farhan Muhamed
Updated on 29-May-2025 19:13:47

7K+ Views

Passing an array by reference is a method of passing arrays to functions in C++ that allows the function to access and modify the original array without creating a copy. In this article, we will learn how to pass arrays by reference, the benefits of this approach, and provide examples. Passing an Array by Reference In the pass by reference approach, the address location of the first element of the array is passed to user defined functions. So, technically, we are passing the same array to that function without creating a copy. The changes made to the array ... Read More

How to use std::sort to sort an array in C++

Farhan Muhamed
Updated on 29-May-2025 19:13:01

9K+ Views

Sorting of an array refer to the process of arranging the elements of the array in ascending or descending order. In this article, we will learn how to use the std::sort function from the C++ STL library to sort an array. In this problem, you are given an array of integers, and you need to arrange the elements in ascending order using std::sort. For example: // Input array int arr[] = {5, 2, 9, 1, 5, 6}; // Output {1, 2, 5, 5, 6, 9} // Explanation: The array is sorted in ascending order. C++ ... Read More

4 Dimensional Array in C/C++

Farhan Muhamed
Updated on 29-May-2025 19:12:08

1K+ Views

4 Dimensional ArrayThe 4 dimensional array is an array of 3 dimensional arrays. Each 3 dimensional array is an array of 2 dimensional arrays and each 2 dimensional array is an array of 1 dimensional arrays. In this article, we will learn all about 4 dimensional arrays, how to create them and how to access their elements with examples in both C and C++. Syntax to Create a 4D Array Following is the syntax for declaring a 4 dimensional array in C/C++: datatype array_name[dimension1][dimension2][dimension3][dimension4]; // Example int arr[3][2][3][4]; Example of a 4 Dimensional Array The ... Read More

Advertisements