Question: Let list be a doubly linked list where each node stores an integer. The Let list be a doubly linked list where each node stores
Let list be a doubly linked list where each node stores an Integer. The prepend(Integer x)method adds a new node to the beginning of list containing the Integer x. The append(Integer x) method adds a new node to the end of Integer x. The add(int idx, Integer x) method adds a new node containing the Integer x to list such that the index of the new node is idx. The remove(int idx) method deletes the node at index idx from list. Consider this code list containing the DList list new DList0 list.prepend (50) list prepend (40) 1ist. remove (1ist.getSize OHIA list.append (30) 1ist prepend (60) 1ist.add (11st.getsize O2 list remove (0) After the last statement is executed, what is the contents of list? list -(50,30,20) O list-(40, 20, 30) list . {40, 30, 20} list-(60, 40, 30, 20)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
