mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-03 02:25:57 +08:00
Update sorting/selection_sort_recursive.cpp
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
@@ -16,22 +16,6 @@
|
||||
/**
|
||||
* @namespace sorting
|
||||
* @brief Sorting algorithms
|
||||
* Selection sort algorithm divides the input list into two parts: a sorted sublist of items which is built up from
|
||||
* left to right at the front (left) of the list and a sublist of the remaining unsorted items that occupy the rest
|
||||
* of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm
|
||||
* proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist,
|
||||
* exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist
|
||||
* boundaries one element to the right.
|
||||
*
|
||||
* Implementation
|
||||
* FindMinIndex
|
||||
* This function finds the minimum element of the array(list) recursively by simply comparing the minimum element of
|
||||
* array reduced size by 1 and compares it to the last element of the array to find the minimum of the whole array.
|
||||
*
|
||||
* SelectionSortRecursive
|
||||
* Just like selection sort, it divides the list into two parts (i.e. sorted and unsorted), and finds the minimum of the
|
||||
* unsorted array by calling FindMinIndex, swaps the minimum element with the first element of the list and then
|
||||
* solves recursively for the remaining unsorted list.
|
||||
*/
|
||||
namespace sorting
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user