# C++ Programming Code Examples

## C++ > Data Structures and Algorithm Analysis in C++ Code Examples

### Shortest path program using STL

C realloc() Allocates size bytes of Memory -
If ptr is null, realloc() allocates size bytes of memory and returns a pointer. If size is zero, the memory pointed to by ptr is freed. There is an error give message: Allocation Error...

C++ Apply the Kruskal's Algorithm to find -
'C++ Program' to find the minimum spanning tree of the given graph. Kruskal's algorithm is a greedy algorithm in graph theory that finds a "Minimum Spanning Tree" for a connected

Implements Max-Flow Min-Cut Theorem -
Program demonstrates implementation of max-flow_min-cut_theorem. So returns true if there is a 'path from source' 's' to sink 't' in residual graph. Also fills parent[] to store the

Find Reverse of a Number using Recursion -
Declare recursive function to find reverse of a number. Lets give a meaningful name to our function, say reverse(). C function computes reverse of number, hence it must accept an...

Code find sum of main diagonal elements -
Read elements in a matrix and find the sum of main diagonal (major diagonal) elements of matrix. Find sum of all elements of main diagonal of a matrix. Input elements in the

C Find Multiplication of 2 Binary Numbers -
Take two binary numbers as input and store it in the variables binary1 and binary2. Initialize the variables multiply and factor with 0 and 1 respectively. Divide the variable binary2 by 10

C++ Additions Subtractions Multiplication -
Perform addition, subtraction, multiplication and division of any two numbers in 'C++', you have to enter the 'two number' and enter the operator to perform the particular operation

Convert Binary Number Octal Vice-Versa -
You will learn to convert "binary number" to octal, and octal number to binary manually by creating a "user-defined" function. In this, first convert the binary number to "decimal".