Professional Documents
Culture Documents
DSA Sort Alg
DSA Sort Alg
DSA Sort Alg
I. Sorting Algorithms
Time Complexity Space
Stability
Algorithms Summary (Case) Complexity
Worst Best
Selects the smallest element from an unsorted list in each
Selection Sort iteration and places that element at the beginning of the O(n2) O(n2) O(1) No
unsorted list.
Places an unsorted element at its suitable place in each
Insertion Sort O(n2) O(n) O(1) Yes
iteration.
Compares two adjacent elements and swaps them if they are
Bubble Sort O(n2) O(n) O(1) Yes
not in the intended order.
Quick Sort Divide and Conquer approach O(n2) O(nlogn) O(logn) No
Merge Sort Divide and Conquer algorithm O(nlogn)) O(nlogn) O(n) Yes
Visualizing the elements of the array as a special kind of
Heap Sort O(nlogn) O(nlogn) O(1) No
complete binary tree called a heap.
Sorts the elements of an array by counting the number of
Counting occurrences of each unique element in the array. The count is
stored in an auxiliary array and the sorting is done by O(n+k) O(n+k) O(max) Yes
Sort
mapping the count as an index of the auxiliary array.