Question: public class HeadList ( Node head: / Points to the first node ot the list ) public class HeadTailList ( Node head; // Points to

 public class HeadList ( Node head: / Points to the first

public class HeadList ( Node head: / Points to the first node ot the list ) public class HeadTailList ( Node head; // Points to the first node of the list Node tail; // Points to the last node of the list h. (1 marks) How do you recognise the last node in a HeadList i. (5 marks) In class HeadList a write a method to add a new node at the end of a HeadList with the following specification: HeadList addToEnd (HeadList list, Node x); // Post: adds x as the last node in list and returns the result Write down the worst case time complexity of your algorithm in terms of the length of the list j. (5 marks) In class HeadTailList write a method to add a new node at the end of a HeadTailList with the following specification HeadTailList addToEnd (HeadTailList 1ist, Node x); // Post: adds x as the last node in list and returns the result Write down the worst case time complexity of your algorithm in terms of the length of the list k. (5 marks) Which type of list out of HeadList and HeadTailList is better for implement- ing a queue data structure? State reasons. (Write no more than 3 lines.)

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!