Sorting Algorithms: Definitions and Comparison
1. Definitions
Algorithm: A step-by-step method to solve a problem. Example: Steps to add two numbers.
Analyzing Algorithms: Studying time and memory usage of algorithms.
Complexity of Algorithms: Amount of time and space an algorithm needs.
Growth of Functions: Shows how time increases with input size.
Performance Measurements: Measures execution time and memory usage.
Sorting: Arranging data in ascending or descending order.
Order Statistics: Finding smallest, largest, or kth element.
Shell Sort: Improved insertion sort using gaps.
Quick Sort: Divide-and-conquer sorting using pivot.
Merge Sort: Divides list, sorts, and merges.
Heap Sort: Uses heap data structure to sort.
Linear Time Sorting: Sorting in O(n) time without comparisons.
2. Comparison of Sorting Algorithms
Algorithm Best Case Average Case Worst Case Stable Extra Space
Shell Sort O(n log n) O(n^1.5) O(n²) No O(1)
Quick Sort O(n log n) O(n log n) O(n²) No O(log n)
Merge Sort O(n log n) O(n log n) O(n log n) Yes O(n)
Heap Sort O(n log n) O(n log n) O(n log n) No O(1)
Counting Sort O(n+k) O(n+k) O(n+k) Yes O(k)
Radix Sort O(nk) O(nk) O(nk) Yes O(n+k)