# Algorithm

Learn different algorithms with detailed explanations and diagrams.

## Bozo-Sort

Bozo-Sort is a variation of Bogosort. It is another highly inefficient randomized algorithm based on the trial and error approach. Bozo-sort sorts the input list by repeatedly swapping 2 random elements of the list and checking if the list is sorted or not. The process is repeated till the input list is sorted. Implementation In …

## Bogosort

Bogosort is just another sorting algorithm. Bogosort is highly inefficient compared to other sorting algorithms. It is a randomized algorithm and is based on the trial and error paradigm. Bogosort basically generates random permutations of the input list and check if the list is sorted or not. This process is continued until the input list …

## Gale Shapley algorithm

Gale Shapley algorithm is used to solve the stable matching problem. It is also known as the Deferred Acceptance algorithm. Stable Matching Problem Stable Matching Problem (also known as Stable Marriage Problem) is the problem to find stable matching between two equally sized sets. The matching is based on the given order of preferences. A …

## C++ Program to Implement Insertion Sort using Templates

In this post, we will discuss how to implement insertion sort using templates. Insertion sort is an in-place sorting algorithm. The array is divided into two-part. One sorted and other unsorted. The elements from unsorted parts are inserted into the sorted part one by one. The advantage of implementing insertion sort using function templates is …

## C++ Program of Binary Search Using Templates

In this post, we will discuss binary search algorithm implementation using function templates in C++. If you don’t know how binary search works, then read Binary Search Algorithm. Program of Binary Search Using Templates Output Program of Binary Search Using Templates (recursive) Output ReadFind all subsets of an arrayProgram to count prime numbers in given …

## C++ Program to Implement Bubble Sort using Templates

In this code, we will discuss program to implement bubble sort using templates in C++. The code is self explanatory. The template function sorts the array in ascending order. The advantage of using template is we don’t have to write different function for different datatypes. Program Output ReadSquare Root Using Binary SearchPrint Diamond Pattern (recursive …

## C++ Program to Implement Merge Sort using Templates

In this post, we will discuss how to implement merge sort using template function in C++. It is important to understand why we use the template function. Templates promote code usability. A single template function can perform a task on different datatypes. We don’t have a write separate functions for each data type. Program Output …

## C++ Program to Implement QuickSort using Templates

C++ Program to Implement quick sort using Templates. A single template function can be used to sort arrays of different datatypes.

## Hierholzer’s Algorithm

Hierholzer’s algorithm is another algorithm to find the Euler Path or Euler circuit in a graph. It’s time complexity is O(E).

## Fleury’s algorithm

Fleury’s algorithm is used to find a Euler Path/Circuit in a connected graph. It is based on the principle that the bridge edge is visited in last.