C Program to sort the string, using shell sort technique.

Shell sort is a generalization of insertion sort that sorts elements far apart before sorting adjacent ones. Invented by Donald Shell in 1959, it repeatedly applies insertion sort on sublists of decreasing “gap” sizes until the gap reaches 1 — at which point one final insertion sort on the nearly-sorted array runs in near-linear time. …

Merge Sort in C – Algorithm, Program, and Complexity

Merge sort in C is a classic divide-and-conquer sorting algorithm that guarantees O(n log n) time in all cases. It splits an array into halves, recursively sorts each half, then merges the sorted halves back together. Unlike bubble sort or insertion sort, merge sort never degrades to O(n²) — making it the preferred choice when …

Insertion Sort in C – Program, Algorithm and Complexity

Insertion sort is one of the simplest sorting algorithms and works exactly the way you sort a hand of playing cards. You take one card at a time and insert it into its correct position among the cards already sorted in your hand. It sorts the array one element at a time, building the sorted …

C Program to Implement Heap Sort — Algorithm, Tree Visualization, and Complexity

Heap Sort is a comparison-based sorting algorithm that uses a binary heap data structure. Its standout property: it is guaranteed O(n log n) in all cases — best, average, and worst — while using only O(1) extra memory. No Quick Sort worst-case surprises, no Merge Sort extra array. Key Concept — The Max-Heap A max-heap …

C Program to Implement Quick Sort — With Explanation and Complexity

Quick Sort is one of the fastest and most widely used sorting algorithms. It uses a divide-and-conquer strategy: pick a pivot element, partition the array so everything smaller than the pivot is on its left and everything larger is on its right, then recursively sort each side. The pivot ends up in its final sorted …

C Program to Sort N Numbers in Descending Order

Sorting in descending order means arranging elements from largest to smallest. The only difference from ascending bubble sort is the direction of the comparison: ascending uses arr[j] > arr[j+1] (swap when left is larger), while descending uses arr[j] < arr[j+1] (swap when left is smaller). This program fixes the original which used void main, a …