Question: //List: ptr to a linked list of Node (each with int data, and Node * next) //Return a pointer to node with the largest value.

//List: ptr to a linked list of Node (each with int data, and Node * next) //Return a pointer to node with the largest value. //You may assume list has at least one element //If more than one element has largest value, //break tie by returning a pointer to the one the occurs //earlier in the list, i.e. closer to the head Node * pointerToMax(Linkedl_ist *list) { //Code may assume that these assertions are true: //so does not need to do error checking for these conditions. assert(list!=NULL): assert(list rightarrow head !=NULL): //TODO: Insert code here to calculate and return //value of pointer to max element (first one if ties.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
