C++ is a general-purpose, high-level compiled programming language that is widely used in the development of applications and software. C++ Algorithm collections contain more than 250 programs, ranging from simple to complex and advanced problems with answers. These C++ algorithms range from simple string matching programs to graph, hard graph, topological sorting, cryptography, random algorithms, shortest path, combinatorial, graph coloring, geometric, and mathematical algorithms.
This section also covers various C++ algorithms on dynamic programming, backtracking, greedy algorithms, STL library, C++ algorithmic functions, data structures, searching, and sorting algorithms. Every example program on these topics includes a program description, C++ code, and program output. All examples have been compiled and tested on Windows and Linux systems.
Here is the listing of C++ Algorithm Topics:
C++ Algorithms:
- C++ Greedy Algorithms
- C++ Algorithms on Dynamic Programming
- C++ Algorithms on Backtracking
- C++ Algorithms on Searching
- C++ Algorithms on Binary Search
- C++ Algorithms on Sorting
- C++ Algorithms on String Matching
- C++ Algorithms on Cryptography
- C++ Algorithms on Tree
- C++ Algorithmic Function
Geometric Algorithms in C++:
Mathematical Algorithms in C++:
Combinatorial Problems in C++:
- Combinatorial Problems in C++
- Permutations & Combinations in C++
- C++ Algorithms on Subset
- Partition Problems in C++
Graph Algorithms in C++:
- C++ Algorithms on Graph
- C++ Algorithms on Graph Connectivity
- C++ Algorithms on Shortest Path
- C++ Algorithms on Graph MST
- C++ Algorithms on Topological Sorting
- C++ Algorithms on Maximum Flow
- C++ Algorithms on Bipartite Graph
- C++ Algorithms on Euler Circuit
- C++ Algorithms on Hard Graph
- C++ Algorithms on Graph Coloring
- Traveling Salesman Problem in C++
- C++ Algorithms on Clique
C++ Programs:
C++ Algorithms on Dynamic Programming
- C++ Program to Emulate N Dice Roller
- C++ Program to Solve the 0-1 Knapsack Problem
- C++ Program to Solve Knapsack Problem Using Dynamic Programming
- C++ Program to Solve Palindrome Partitioning Problem
- C++ Program to Perform Optimal Parenthesize using Dynamic Programming
- C++ Program to Implement Kadane’s Algorithm
- C++ Program to Find the Size of Largest Independent Set (LIS) in a Binary Tree
- C++ Program to Implement a Heuristic to Find the Vertex Cover of a Graph
- C++ Program to Find the Longest Increasing Subsequence
- C++ Program to Find All Pairs Shortest Path
C++ Algorithms on Searching
- C++ Program to Implement the KMP Pattern Searching Algorithm
- C++ Program to Implement Rabin-Karp Algorithm
- C++ Program to Implement Interpolation Search Algorithm
- C++ Program to Implement Z-Algorithm
- C++ Program to Implement Linear Search
- C++ Program to Perform Searching Using Self-Organizing Lists
- C++ Program to Perform Searching based on Locality of Reference
- C++ Program to Implement Linear Search using Recursion
- C++ Program to Find Minimum Element in an Array using Linear Search
- C++ Program to Find kth Largest Element in a Sequence
- C++ Program to Find the Median of Two Sorted Arrays using Divide and Conquer
- C++ Program to Search Sorted Sequence using Divide and Conquer
- C++ Program to Find Second Smallest of n Elements with Complexity Constraint
- C++ Program to Find K Closest Median Elements
- C++ Program to Find Median of Two Arrays of Different Sizes
- C++ Program to Perform Finite State Automata based Search
C++ Algorithms on Binary Search
- C++ Program to Compare Binary and Sequential Search
- C++ Program to Perform Uniform Binary Search
- C++ Program to Implement Binary Search using Iteration
- C++ Program to Find Maximum Element in an Array using Binary Search
- C++ Program to Find a Search Sequence using Binary Search
- C++ Program to Find Minimum Element in an Array using Binary Search
- C++ Program to Find Peak Element of an Array using Binary Search
- C++ Program to Count Number of Occurrences of a Given Number using Binary Search
- C++ Program to Find the Maximum Subarray Sum using Divide and Conquer
- C++ Program to Find the Median of Two Sorted Arrays using Binary Search
C++ Algorithms on Sorting
- C++ Program to Implement Insertion Sort
- C++ Program to Implement Selection Sort
- C++ Program to Implement Bubble Sort
- C++ Program to Implement Merge Sort
- C++ Program to Implement Shell Sort
- C++ Program to Implement Heap Sort
- C++ Program to Implement Radix Sort
- C++ Program to Implement Counting Sort
- C++ Program to Implement Bucket Sort
- C++ Program to Implement Stooge Sort Algorithm
- C++ Program to Implement Shaker Sort
- C++ Program to Sort Linked List using Merge Sort
- C++ Program to Implement Quick Sort Using Randomization
- C++ Program to Implement Quick Sort with Given Complexity Constraint
- C++ Program to Sort of 10 Elements Using Heap Sort Algorithm
- C++ Program to Count Inversions in an Array
- C++ Program to Implement Sorting of Less than 100 Numbers in O(n) Complexity
C++ Algorithms on String Matching
- C++ Program to Perform Naive String Matching
- C++ Program to Implement Boyer-Moore Algorithm for Pattern Searching
- C++ Program to Implement Aho-Corasick Algorithm for Pattern Searching
- C++ Program to Implement Rabin-Karp Method for Pattern Searching
- C++ Program to Implement Levenshtein Distance Computing Algorithm
- C++ Program to Repeatedly Search the Same Text
C++ Algorithms on Cryptography
- C++ Program to Implement the Monoalphabetic Cipher
- C++ Program to Implement Caesar Cipher
- C++ Program to Implement the Vigenere Cipher
- C++ Program to Implement the Hill Cipher
- C++ Program to Implement Affine Cipher
- C++ Program to Encrypt Message using Playfair Cipher
- C++ Program to Decrypt Message using Playfair Cipher
- C++ Program to Implement the One Time Pad Algorithm
- C++ Program to Implement the RSA Algorithm
C++ Algorithmic Function
- C++ Program to Print Map using for_each Function
- C++ Program to Illustrate the transform() Function
- C++ Program to Demonstrate the replace() Algorithm
- C++ Program to Demonstrate the fill_n() Function
- C++ Program to Demonstrate the generate() Function
- C++ Program to Demonstrate the remove() Function
- C++ Program to Demonstrate the adjacent_find() Algorithm
- C++ Program to Demonstrate the lexicographical_compare() Algorithm
- C++ Program to Swap Elements Using iter_swap() Algorithm
- C++ Program to Rearrange Container Elements using stable_partition() Algorithm
Robust Geometric Primitives in C++
- C++ Program to Find the Area of a Triangle Using Determinants
- C++ Program to Find the Volume of a Tetrahedron Using Determinants
- C++ Program to Find Area of a Polygon using Slicker Algorithm
- C++ Program to Use Above Below Primitive to Test Whether Two Lines Intersect
- C++ Program to Find if a Point Lies Inside or Outside a Circle
- C++ Program to Apply Above-Below-on Test to Find the Position of a Point with respect to a Line
Numerical Algorithms in C++
- C++ Program to Implement Booth’s Multiplication Algorithm for Multiplication
- C++ Program to Implement the Schonhage-Strassen Algorithm for Multiplication
- C++ Program to Perform Partition of an Integer in All Possible Ways
- C++ Program to Implement the Bin Packing Algorithm
- C++ Program to Perform the Unique Factorization of a Given Number
- C++ Program to Find GCD of Two Numbers Using Recursive Euclid Algorithm
- C++ Program to Optimize Wire Length in Electrical Circuit
- C++ Program to Perform Optimal Parenthesize using Dynamic Programming
Randomized Algorithms in C++
- C++ Program to Generate Random Numbers in a Range
- C++ Program to Use rand and srand Functions
- C++ Program to Generate N Number of Passwords of Length M Each
- C++ Program to Emulate N Dice Roller
- C++ Program to Generate Random Hexadecimal Bytes
- C++ Program to Implement the Linear Congruential Generator
- C++ Program to Generate Random Numbers Using Middle Square Method
- C++ Program to Generate Random Numbers Using Multiply with Carry Method
- C++ Program to Generate Random Numbers Using Probability Distribution Function
- C++ Program to Implement Fisher-Yates Algorithm
- C++ Program to Implement Park-Miller Random Number Generation Algorithm
- C++ Program to Implement Naor-Reingold Pseudo Random Function
C++ Algorithms on Sieve & Primality Test
- C++ Program to Implement Segmented Sieve
- C++ Program to Implement Sieve of Atkins
- C++ Program to Implement Wheel Sieve to Generate Prime Numbers
- C++ Program to Generate Prime Numbers Using Sieve of Sundaram
- C++ Program to Perform Fermat Primality Test
- C++ Program to Implement Miller Rabin Primality Test
- C++ Program to Implement Solovay-Strassen Primality Test
Permutations & Combinations in C++
- C++ Program to Generate All Possible Combinations of a Given List of Numbers
- C++ Program to Generate a Sequence of N Characters for a Given Specific Case
- C++ Program to Implement Heap’s Algorithm for Generating Permutations
- C++ Program to Implement Alexander Bogomolny’s UnOrdered Permutation Algorithm
- C++ Program to Compute Combinations using Factorials
- C++ Program to Compute Combinations using Recurrence Relation for nCr
- C++ Program to Compute Combinations using Matrix Multiplication
C++ Algorithms on Subset
- C++ Program to Generate a Random Subset by Coin Flipping
- C++ Program to Generate All Possible Combinations
- C++ Program to Generate All Possible Subsets
- C++ Program to Generate All Pairs of Subsets whose Union Make the Set
- C++ Program to Generate All Possible Subsets using Gray Code Order
- C++ Program to Generate All Possible Subsets using Lexicographic Order
- C++ Program to Generate All Possible Subsets using Binary Counting Method
C++ Algorithms on Graph
- C++ Program to Check if Path Exists in a Graph
- C++ Program to Check if Graph is DAG
- C++ Program to Find the Longest Path in a Directed Acyclic Graph
- C++ Program to Implement Stable Marriage Problem
- C++ Program to Find Maximum Number of Edge Disjoint Paths
- C++ Program to Generate a Random UnDirected Graph for a Given Number of Edges
- C++ Program to Generate a Random Directed Acyclic Graph DAC for a Given Number of Edges
- C++ Program to Create a Random Graph using Random Edge Generation
- C++ Program to Create a Random Graph using Random Edge Selection
- C++ Program to Generate a Graph for a Given Fixed Degree Sequence
- C++ Program to Check if Degree Sequence can Form Any Graph
C++ Algorithms on Graph Connectivity
- C++ Program to Traverse a Graph using BFS
- C++ Program to Traverse a Graph using DFS
- C++ Program to Check the Connectivity of Directed Graph Using BFS
- C++ Program to Check the Connectivity of Directed Graph Using DFS
- C++ Program to Check the Connectivity of Undirected Graph Using BFS
- C++ Program to Check the Connectivity of Undirected Graph Using DFS
- C++ Program to Check if a Directed Graph is a Tree or Not using DFS
- C++ Program to Check if an UnDirected Graph is a Tree or Not using DFS
- C++ Program to Check whether Graph is Biconnected or Not
- C++ Program to Check if a Graph is Strongly Connected or Not
- C++ Program to Find the Connected Components in an UnDirected Graph
- C++ Program to Check if a Directed Graph is Weakly Connected or Not using DFS
- C++ Program to Check if a Directed Graph is Strongly or Weakly Connected
- C++ Program to Find the Minimum Number of Edges to Remove to Disconnect a Graph
- C++ Program to Find the Edge Connectivity of a Graph
- C++ Program to Find the Vertex Connectivity of a Graph
- C++ Program to Find Number of Articulation Points in a Graph
C++ Algorithms on Shortest Path
- C++ Program to Find Shortest Path in a DAG using Topological Sorting
- C++ Program to Implement Dijkstra’s Algorithm using Queue
- C++ Program to Implement Dijkstra’s Algorithm using Priority Queue
- C++ Program to Implement Dijkstra’s Algorithm using Set
- C++ Program to Implement Bellmanford Algorithm
- C++ Program to Find the Shortest Path using Bellmanford Algorithm
- C++ Program to Implement Floyd-Warshall Algorithm
- C++ Program to Find All Pairs Shortest Path
- C++ Program to Find the Transitive Closure of a Graph
- C++ Program to Find the Transitive Closure of a Graph using Warshall’s Algorithm
- C++ Program to Implement Johnson’s Algorithm
- C++ Program to Find Single Source Shortest Path in DAG
C++ Algorithms on Topological Sorting
- C++ Program for Topological Sorting in Graphs
- C++ Program to Detect Cycle in a Graph using Topological Sort
- C++ Program to Perform the Topological Sorting of a Directed Acyclic Graph using DFS
- C++ Program to Create a Random Linear Extension for a DAG
- C++ Program to Remove the Edges in a Cyclic Graph
C++ Algorithms on Hard Graph
- C++ Program to Solve the Dominating Set Problem
- C++ Program to Check Whether a Vertex Cover of Size k Exists or Not
- C++ Program to Find Hamiltonian Cycle
- C++ Program to Implement the Vizing’s Theorem
- C++ Program to Find a Good Feedback Edge Set in a Graph
- C++ Program to Find a Good Feedback Vertex Set in a Graph
C++ Algorithms on Graph Coloring
- C++ Program to Perform Greedy Coloring
- C++ Program to Perform Edge Coloring of a Graph
- C++ Program to Perform Edge Coloring for the Complete Graph
- C++ Program to Perform Edge Coloring to the Line Graph of an Input Graph
- C++ Program to Perform Graph Coloring on Bipartite Graphs
- C++ Program to Find Independent Sets in a Graph by Graph Coloring
- C++ Program to Find Chromatic Index of Cyclic Graphs
- C++ Program to Implement a Heuristic to Find the Vertex Cover of a Graph