Consider the following problem.
Input: Two arrays A[] and B[].
Output: True if A[] is an exact shuffle of B[].
A[] is a shuffle of B[] if they contain exactly the same elements in potentially
different locations.
You will solve this question 2 times.
First, solve the problem to use the minimum runtime. There is NO requirement
on the space complexity for this solution (we put time ahead of space, which
means you can use extra data structure. create new arrays, etc).
Second, solve the problem to use the minimum space. There is NO
requirement on the runtime complexity for this solution (this time we put
space ahead of time, which means your solution does not need to be the
fastest).
Examples:
A[] = {1, 2, 3, 4, 5}; B[] = {2, 3, 1, 5, 4}; // should return true
A[] = {1, 2}; B[] = {2, 3, 1, 5, 4}; // should return false
For each solution,
a. Provide pseudocode. (5 points).
b. Analyze its run time. (2 points).
c. Analyze its space complexity (how much space does it use?) (2
points).