C++ Sorting The parameter to the following two recursive routines is a pointer t
ID: 3935966 • Letter: C
Question
C++ Sorting
The parameter to the following two recursive routines is a pointer to a singly linked list of numbers, whose elements are unique (no duplicates) and unsorted. Each node in the list contains two members, info (a number) and next (a pointer to the next node). Write a recursive value-returning function, MinLoc, that receives a pointer to a list of unsorted numbers and returns a pointer to the node that contains the minimum value in the list. Write a recursive void function, Sort, that receives a pointer to an unsorted list of numbers and reorders the values in the list from smallest to largest. This function may call the recursive MinLoc function that you wrote in partExplanation / Answer
Here is the solution for part(a):
int linked_list::MinLoc(node *head)
{
if(head == NULL)
return -1;
else if(head->next == NULL)
return head->info;
else
return (head->info < MinLoc(head->next) ? head->info : MinLoc(head->next));
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.