Shell Sort in C++

This C++ Program implements Shell Sort Algorithm. Shell sort is a sorting algorithm. It is an in-place comparison sort and one of the oldest sorting algorithm. Shell sort is a generalization of insertion sort that allows the exchange of items that are far apart. Shell sort is not stable sort. It takes O(1) extra space. The worst case time complexity…

Heap Sort in C++

Heap Sort: Heap sort is a comparison based sorting technique based on Binary Heap data structure. It is similar to selection sort where we first find the maximum element and place the maximum element at the end. We repeat the same process for remaining element. Binary Heap: Let us first define a Complete Binary Tree. A complete binary tree is…

Insertion Sort in C++

Simplest Program for insertion Sort in C++ How it works?   A graphical example of insertion sort. Source: Wikipedia PROGRAM: #include <iostream> using namespace std; int main() { int a[16], i, j, k, temp; cout<<“enter the elementsn”; for (i = 0; i < 5; i++) { cin>>a[i]; } for (i = 1; i < 5; i++) { for (j =…