Question: a) Given two sorted lists, Li and L2, complete a following procedure in Java to compute L1 L2 = { x 1 x L1



a) Given two sorted lists, Li and L2, complete a following procedure in Java to compute L1 \ L2 = { x 1 x L1 and x L2 } using only the basic list operators (next(), hasNext), and compareTo and one loop public static > void difference(List L1, List L2, ListAnyType Difference) ListIterator AnyType iterl1- L1.listIterator(); ListIterator AnyType iterL2 L2.1istIterator(); if ( iterL1.hasNext() && iterL2.hasNext)) itemL1 iterL1.next); itemL2iterL2.next); /I YOUR CODE GOES HERE b) Write a method in Java to sort a stack of n integer numbers, s, in descending order static Stack sort(Stack s) To implement this method you must use one more auxiliary stack and you should not make any assumptions about how the stack is implemented. The following are the only functions that should be used to write this program: push, pop, peek, and isEmpty. What is the running time complexity of your method? Justify Important Notes For this problem, you only need to submit the implementation of two methods in Java (difference and sort) In the case of your sort method don't forget to indicate (and justify) the running time complexity of your solution Problem #2: (30 pts) Given an array A of n integers, a leader element of the array A is the element that appears more than half of the time in A Using one stack, implement in Java an O(n) running time complexity method static int leader(int] A) to find a leader element and return the index (any) of the leader in A. The program must returns -1 if no leader element exists Examples intl] a-(23, 23, 67, 23, 67, 23, 45};leader(a)-5 intl] a-(23, 24, 67, 23, 67, 23, 45};leader(a)1 Important Notes . You must add the main method in your program in order to test your implementation