intersect, shown below, returns the number of elements that are in both lists. Assume both lists contain N items.
a. What is the running time of intersect when both lists are ArrayLists?
b. What is the running time of intersect when both lists are LinkedLists?
c. Suppose it takes 4 seconds to run intersect on two equally-sized 1,000-item LinkedLists. How long will it take to run intersect on two equally-sized 3,000-item LinkedLists?
d. Does rewriting the two loops using the enhanced for loop (i.e. for( int x : c1 ) ) make intersect more efficient? Provide an explanation of your reasoning.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here