Selection Sort:
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning.
arr[] = 64 25 12 22 11 // Find the minimum element in arr[0...4] // and place it at beginning 11 25 12 22 64 // Find the minimum element in arr[1...4] // and place it at beginning of arr[1...4] 11 12 25 22 64 // Find the minimum element in arr[2...4] // and place it at beginning of arr[2...4] 11 12 22 25 64 // Find the minimum element in arr[3...4] // and place it at
Insertion Sort:
Merge Short.
QuickSort
2.9
Like Merge
Sort,
QuickSort is a Divide and Conquer algorithm. It picks an element as
pivot and partitions the given array around the picked pivot. There
are many different versions of quickSort that pick pivot in different
ways.
-
Always pick first element as pivot.
-
Always pick last element as pivot (implemented below)
-
Pick a random element as pivot.
Heap Sort. Input data: 4, 10, 3, 5, 1 4(0) / \ 10(1) 3(2) / \ 5(3) 1(4) The numbers in bracket represent the indices in the array representation of data. Applying heapify procedure to index 1: 4(0) / \ 10(1) 3(2) / \ 5(3) 1(4) Applying heapify procedure to index 0: 10(0) / \ 5(1) 3(2) / \ 4(3) 1(4) The heapify procedure calls itself recursively to build heap in top down manner.
The Radix Sort Algorithm
1) Do following for each digit i where i varies from least significant digit to the most significant digit.
………….a) Sort input array using counting sort (or any stable sort) according to the i’th digit.
Example:
Original, unsorted list:
Original, unsorted list:
- 170, 45, 75, 90, 802, 24, 2, 66
Sorting
by least significant digit (1s place) gives: [*Notice that we keep
802 before 2, because 802 occurred before 2 in the original list, and
similarly for pairs 170 & 90 and 45 & 75.]
- 170, 90, 802, 2, 24, 45, 75, 66
Sorting
by next digit (10s place) gives: [*Notice that 802 again comes before
2 as 802 comes before 2 in the previous list.]
- 802, 2, 24, 45, 66, 170, 75, 90
Sorting
by most significant digit (100s place) gives:
- 2, 24, 45, 66, 75, 90, 170, 802
Bucket Search:
ref: https://www.geeksforgeeks.org/






Comments
Post a Comment