
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2673 of 3366

180 Views
In this program a random graph is generated for random vertices and edges. The time complexity of this program is O(v*e). Where v is the number of vertices and e is the number of edges.AlgorithmBegin Develop a function GenRandomGraphs(), with ‘e’ as the number of edges and ‘v’ as the number of vertexes, in the argument list. Assign random values to the number of vertex and edges of the graph, Using rand() function. Print the connections of each vertex, irrespective of the direction. Print “Isolated vertex” for the vertex having no ... Read More

284 Views
This is a C++ Program to Generate N Number of Passwords of Length M Each.AlgorithmBegin Take the length of password as input. function permutation() generate random passwords: /* Arguments A pointer array a. Total Number of random numbers m. Length of the password s. */ // Body of the function: if (m == s) for i = 0 to s-1 Print *(a + i) else for i = m to s-1 ... Read More

2K+ Views
This is a C++ program to implement Modular Exponentiation Algorithm.AlgorithmBegin function modular(): // Arguments: base, exp, mod. // Body of the function: initialize res = 1 while (exp > 0) if (exp mod 2 == 1) res= (res * base) % mod exp = exp left shift 1 base = (base * base) % mod return res. EndExample#include using namespace std; long long modular(long long base, long long exp, int mod) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res= (res * base) % mod; exp = exp >> 1; base = (base * base) % mod; } return res; } int main() { long long b, e; int mod; coutb; coute; coutmod; cout

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 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

310 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

216 Views
This is a C++ program to perform Optimal Paranthesization using Dynamic Programming.AlgorithmBegin Take the length n and dimension of matrix as input. MatrixChain() to find out minimum multiplications: Arguments: a[i][j]=Minimum number of scalar multiplications needed to compute the matrix A[i]A[i+1]...A[j] = A[i..j] where dimension of A[i] is p[i-1] x p[i]. a[i][j] means cost is zero when multiplying one matrix. L is chain length. m = cost / scalar multiplications. Body of the function: for i = ... Read More

359 Views
This is a C++ Program to optimize Wire Length in Electrical Circuit.AlgorithmBegin Function optimizeLength() : 1) Declare a array dist[N]. 2) sptSet[i] will be true if component i is included in shortest path tree or shortest distance from src to i is finalized. 3) Initialize all distances as INFINITE and stpSet[] as false 4) Distance of source component from itself will be always 0. 5) Run a for loop cnt = 0 to N-2, Find shortest path for all components. A) Pick the minimum distance component from the set of ... Read More

578 Views
This is a C++ program to represent Linear Equations in matrix form.AlgorithmBegin 1) Take the no of variables n and the coefficients of each variable as input. 2) Declare a matrix[n][n] and constant[n][1]. 3) Make for loops i = 0 to n-1 and j = 0 to n-1 to take the coefficients of each variable as the elements of the matrix. 4) Display the matrix by using nested for loops. EndExample#include using namespace std; int main(void) { char variable[] = { 'x', 'y', 'z', 'd' }; cout > n; cout > matrix[i][j]; } cin >> constant[i][0]; } cout

4K+ Views
Gauss Seidel method is used to solve linear system of equations in iterative method. This is a C++ Program to Implement Gauss Seidel Method.AlgorithmBegin Take the dimensions of the matrix p and its elements as input. Take the initials values of x and no of iteration q as input. While q>0 Make a for loop i = 0 to p-1 initialize n[i] = (b[i] / a[i][i]). Make a for loop i = 0 to p-1 If (j == ... Read More

540 Views
Freivalds' algorithm determines whether the matrices are equal for a chosen k value with a probability of failure less than 2^-k in O(kn^2).It is used to verify matrix multiplication.AlgorithmBegin Take matrix1(n*n), matrix2(n*n), matrix3(n*n) as input. // According to the algorithm we have to verify: // matrix1 × matrix2 = matrix3. 1) Choose vector a[n][1] randomly and uniformly in which component will be 0 or 1. 2) Compute matrix2 * a, matrix3 * a and then matrix1 * (matrix2 * a) for evaluating the expression, matrix1 * (matrix2 * a) - matrix3 * a. 3) ... Read More