# Category Archives: C++ Programs

The Stooge sort is a recursive sorting algorithm. It is defined as below (for ascending order sorting). Step 1 : If value at index 0… Read More
The GCD of three or more numbers equals the product of the prime factors common to all the numbers, but it can also be calculated… Read More
Background : Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. Following is… Read More
Cycle sort is an in-place sorting Algorithm, unstable sorting algorithm, a comparison sort that is theoretically optimal in terms of the total number of writes… Read More
Given two integer numbers, the task is to find the count of all common divisors of given numbers. Input : a = 12, b =… Read More
BogoSort also known as permutation sort, stupid sort, slow sort, shotgun sort or monkey sort is a particularly ineffective algorithm based on generate and test… Read More
This is basically a variation of bubble-sort. This algorithm is divided into two phases- Odd and Even Phase. The algorithm runs until the array elements… Read More
Algorithm Steps If you are at the start of the array then go to the right element (from arr to arr). If the current array… Read More
Cocktail Sort is a variation of Bubble sort. The Bubble sort algorithm always traverses elements from left and moves the largest element to its correct… Read More
Bitonic Sequence A sequence is called Bitonic if it is first increasing, then decreasing. In other words, an array arr[0..n-i] is Bitonic if there exists… Read More
Bitonic Sequence A sequence is called Bitonic if it is first increasing, then decreasing. In other words, an array arr[0..n-i] is Bitonic if there exists… Read More
Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements and the number of possible key… Read More
Comb Sort is mainly an improvement over Bubble Sort. Bubble sort always compares adjacent values. So all inversions are removed one by one. Comb Sort… Read More
Given a number, find a representation of number as sum of non-consecutive Fibonacci numbers.Examples: Input: n = 10 Output: 8 2 8 and 2 are… Read More
In shellSort, we make the array h-sorted for a large value of h. We keep reducing the value of h until it becomes 1. An… Read More