Question: Decoding LinkedList Question 1: The LinkedList class uses another class called Node (which is defined inside LinkedList.java). What are the fields in the Node class?

Decoding LinkedList

Question 1: The LinkedList class uses another class called Node (which is defined inside LinkedList.java). What are the fields in the Node class?

Question 2: The Node class uses generics. Why?

Question 3:The linkFirst method contains the following lines of code: if (f == null) last = newNode; else f.prev = newNode;

What is the value of the linked lists size attribute at this point in the code if f ==null is true?

Question 4: True or False: the removeLast method will take longer to execute the more items are in the linked list.

Question 5: True or False: the public void add(E e) method always adds the new item at the beginning of the linked list.

Question 6: True or False: the public void add(E e) method will take longer to execute the more items are in the linked list.

Question 7:The unlink method contains the following lines of code: if (prev == null) { first = next; } else { prev.next = next; x.prev = null; }

If the method is called with the first Node in the list as the parameter value, which of these will be executed: the if clause or the else clause?

Question 8: True or false: in general, the containsmethod takes longer to execute the more items there are in the linked list.

Question 9: The indexOf method always returns -1 if it is passed a null argument?

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!