Need help with 1and 2 please! please!

Image transcriptions

(a) [4 points] Suppose the linked list looks like this initially: A > B > c> D->E. What will it look like after the code above executes? (b) [2 points] The code above will produce a null pointer exception if the list is empty. Which line of the code will produce this error and why it is produced. (c) [2 points] What is the Big-O running time of the code above assuming that the list has n items? For each of the following problems, make sure your implementation works when the list is empty, has one element and multiple elements. 3. [8 points] (a) (6 pts) Complete the contains method on page 917 of your textbook. You may assume that the elements of your list have a equals method. (b) (2 pts) What is the running time of your method in Big-O terms. Give a brief reason. 4. [8 points] (a) Complete the method removeFront below which takes the head of a linked list and an int num and removes the first num elements from the list. Your method cannot use any calls to remove. public void removeFront (Node head, int num) { (a) (2 pts) What is the running time of your method in Big-O terms. Give a brief reason.

1. (6 points) State the worst case and average case running times of the methods below. For full credit provide brief explanations. (a) public ArrayList<Integer> populateList (int n) { ArrayList<Integer> list = new ArrayList<Integer>() ; for (int 1=0; 1< n; it+) list . add (i) ; return list; (b) public ArrayList<Integer> populateList (int n) { ArrayList<Integer> list = new ArrayList<Integer>() ; for (int i=0; i< n; it+) list . add (0, i) ; return list ; (c) public int getLargerValue (ArrayList<Integer> list, int i, int j) { int ans - if (list . get (i) > list.get (j) ) ans= list. get (i ) ; else ans - list . get (i ) ; return ans; 2 . (8 pts) In the following code, assume that head is the head of a linked list and it is an object of type Node. Node prev - head; Node cur = prev. next; while ( cur ! =null) < Node temp - cur . next; cur . next - prev; prev = cur; cur = temp; head. next - null; tail - head; head - prev; MacBook Pro

**378,310 students got unstuck** by Course

Hero in the last week

**Our Expert Tutors** provide step by step solutions to help you excel in your courses