File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 496
496
497
497
![ ] ( https://github.com/aish21/Algorithms-and-Data-Structures/blob/main/Resources/Animations/Merge-Sort.gif )
498
498
499
- ### [ Quick Sort] ( /Practice%20Concepts/Sorting/merge -sort.py )
499
+ ### [ Quick Sort] ( /Practice%20Concepts/Sorting/quick -sort.py )
500
500
* Based on the Divide and Conquer strategy
501
501
* Method:
502
502
1 . Select the pivot element: Different variations have different methods of picking the pivot elements. The most basic one picks the right-most element as the pivot element.
515
515
516
516
![ ] ( https://github.com/aish21/Algorithms-and-Data-Structures/blob/main/Resources/Animations/quicksort.gif )
517
517
518
+ ### [ Counting Sort] ( /Practice%20Concepts/Sorting/quick-sort.py )
519
+ * Sorts the elements of an array by counting the number of occurances of each unique element in the array.
520
+ * The count is stored in an auxiliary array and the sorting is done by mapping the count as an index of the auxiliary array.
521
+ * Method:
522
+ - Find out the maximum element
523
+ - Initialize an array of length max+1 with all elements 0. This array is used for storing the count of the elements in the array.
524
+ - Store the count of each element at their respective index in the 'count' array
525
+ - Store cumulative sum of the elements of the count array. It helps in placing the elements into the correct index of the sorted array.
526
+ - Find the index of each element of the original array in the count array. This gives the cumulative count.
527
+ - After placing each element at its correct position, decrease its count by one
528
+ * Time Complexity - Best, Average and Worst: O(n + k) - There are mainly four main loops
529
+ * Space Complexity - O(max)
530
+
531
+ ![ ] ( https://github.com/aish21/Algorithms-and-Data-Structures/blob/main/Resources/Animations/counting-sort.gif )
518
532
519
533
## Search Algorithms
520
534
<p align =" center " >
You can’t perform that action at this time.
0 commit comments