Question: Linked List - Find Largest Recursive Write the body for the largest function: T largest(Node * current) It should recursively get the largest value in

Linked List - Find Largest Recursive

Write the body for the largest function:

T largest(Node* current)

It should recursively get the largest value in the list starting at current. You may assume that the function will not be passed a nullptr. Hints:

  • Your base case should be "there is no one after me, my value is largest!"
  • The general case should compare the value in the current node with the largest in the rest of the list.

Linked List - Find Largest Recursive Write the body for the largest

include define for NoFors define while NoWhiles #define goto NoGotos 6 using namespace std; 8 template typename T 9class Node ( 10 public: //Value stored in this node T element; //Next node in 1ist (nullptrend of list) Node* next nullptr; 12 13 14 15 16 17 18i 19 20 21 template 22 T largest (Node * head new Nodechar>( 'B' ); char largestVallargest (head); cout next new Node ('N head->next->next = new Node( 'A' ); largestVallargest(head) cout next->next->next = new largestVallargest (head); cout ('R' ) ; 45 46 47 48

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!