In: Computer Science
What property does a custom class need to have for it to be usable in an array with the three sort methods you implemented? Give a name to the concept and also explain specifically in C++ what would need to be implemented.
Lets consider 3 sorting techniques,
1. Merge sort : Here the custom class will need 3 pointers, i.e. one pointing to the first element of an array, one pointing to the middle and one pointing to the last. Then we use divide and conquer rule to complete this merge sort procedure unless all the elements are in a sorted order.
2. Selection Sort: here we need two pointers, initially pointing to the first element, then the second pointer will iterate through entire array by comparing all the elements with the first element, and the first element is swapped by the smallest element and so on.
3. Quick Sort: Here we consider a pivot element,so the custom class needs 3 variables and two pointer pointing to the first and last element, and then bringing the pivot element to its right position.
Note: If you have any doubts or queries, feel free to ask by commenting down below.
And if my answer suffice to the requirements, then kindly upvote as an appreciation
Happy Learning :)