Tutorial Exercises:
How many comparisons are made in expectation by quick-sort on an array containing the following elements:
[3, 4, 5]
Can you generalize this to any length 3 array? What about length n arrays?
Consider the following problem.
We have a pair of lists of integers each of length n.
Each list contains no duplicates.
Determine if there is an integer j where j is in both lists.
Your technique should run in time O(n) in expectation. You may make certain probabilistic assumptions.
What about if we have k lists? Can you generalize your technique to determine if there is an integer j that is in all k lists?
Your technique should now run in time O(nk) in expectation.