Question: Here are the class definitions of Node and List that implement a linked list. class Node 1 private Node next; private int key: Node (Node

 Here are the class definitions of Node and List that implement

Here are the class definitions of Node and List that implement a linked list. class Node 1 private Node next; private int key: Node (Node nxt, int keyValue); // constructor Node getNext); int getKey) void putNext (Node nxt); class List 1 // assume the class does not use a dummy Node private Node head; List); boolean exists(int ky); // returns true if ky is in the list void insertAtHead(int ky); // inserts at the beginning of the list void insertAtTail(int ky); // inserts at the end of the list int removeFromHead ); void delete(int ky); // delete the element or do nothing if ky doesn't exist int removeSmallest ); // removes the Node containing the smallest key // constructor // Returns -1 if the list is empty // and returns that key. Returns -1 if the list is empty // Could be duplicate entries, so remove the first int removeLargest; // removes the Node containing the largest key // and returns that key. Returns -1 if the list is empty // Could be duplicate entries, so remove the first int maxElement); / calls the private version, doesn't delete the Node int sum(); int length // calls the private version // calls the private version private int maxElement (Node x); private int sum (Node x); private int length (Node x); 1. Write the function void insertAtTail(int ky). Don't add any class variables to the List class. 2. Write the private iterative function void delete(int ky) using only ONE reference variable that marches along the list (my notes use two reference variables, ref and prev) 3. Write the private recursive function int maxElement (Node x) 4. Write the private recursive function int sum (Node x) to find the sum of the keys stored in a List

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!