diff --git a/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/104-selection-sort.md b/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/104-selection-sort.md index 2727c30ad..6b5889786 100644 --- a/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/104-selection-sort.md +++ b/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/104-selection-sort.md @@ -1,3 +1,9 @@ # Selection Sort Selection Sort is a simple and intuitive sorting algorithm. It works by dividing the array into two parts - sorted and unsorted. Initially, the sorted part is empty and the unsorted part contains all the elements. The algorithm repeatedly selects the smallest (or largest, if sorting in descending order) element from the unsorted part and moves that to the end of the sorted part. The process continues until the unsorted part becomes empty and the sorted part contains all the elements. Selection sort is not efficient on large lists, as its time complexity is O(n²) where n is the number of items. + +Learn more from the following resources: + +- [@article@Selection Sort - W3Schools](https://www.w3schools.com/dsa/dsa_algo_selectionsort.php) +- [@article@Selection Sort Visualize](https://www.hackerearth.com/practice/algorithms/sorting/selection-sort/practice-problems/) +- [@video@Selection sort in 3 minutes](https://www.youtube.com/watch?v=g-PGLbMth_g&t=5s) diff --git a/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md b/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md index 382b6f8c5..62f9383ce 100644 --- a/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md +++ b/src/data/roadmaps/datastructures-and-algorithms/content/105-sorting-algorithms/105-heap-sort.md @@ -1,3 +1,9 @@ # Heap Sort Heap Sort is an efficient, comparison-based sorting algorithm. It utilizes a data structure known as a 'binary heap', and works by dividing its input into a sorted and an unsorted region, and iteratively shrinking the unsorted region by extracting the largest element and moving that to the sorted region. It's an in-place algorithm but not a stable sort. It involves building a Max-Heap, which is a specialized tree-based data structure, and then swapping the root node (maximum element) with the last node, reducing the size of heap by one and heapifying the root node. The maximum element is now at the end of the list and this step is repeated until all nodes are sorted. Heap Sort offers a good worst-case runtime of O(n log n), irrespective of the input data. + +Learn more from the following resources: + +- [@article@Heap Sort - W3Schools](https://www.geeksforgeeks.org/heap-sort/) +- [@article@Heap Sort Visualize](https://www.hackerearth.com/practice/algorithms/sorting/heap-sort/tutorial/) +- [@video@Heap sort in 4 minutes](https://www.youtube.com/watch?v=2DmK_H7IdTo)