Question: For this exercise, a linked list is built using the following struct. The type Item is defined elsewhere. struct node { Item data; struct node
For this exercise, a linked list is built using the following struct. The type Item is defined elsewhere. struct node { Item data; struct node * next; }; Write the definition of a function named sortList that creates a new copy of a list and arranges that copy in sorted order. The function takes one argument, a list (i.e., a pointer to the head of a list). It returns a pointer to the new list. The new list must contain the same values as the original list, in sorted order (low to high). The following function is available for you to use: int lessThan(Item, Item); /* returns 1 if first item is less than second, 0 otherwise */ The original list MUST NOT be changed. (NOTE: The original list may be empty.) The function must create NEW nodes for the copy. You cannot use the same nodes that are in the original list. Also, assume that an Item can be copied using the assignment operator (=). All I need is the function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
