C Sorting The parameter to the following two recursive routi

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 part

Solution

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));
}

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site