Question: 5. Stack (13 points) (About max in Stack) If we perform the following operations on an empty stack: push 2 push 3 push 2 push

5. Stack (13 points) (About max in Stack) If we perform the following operations on an empty stack: push 2 push 3 push 2 push 4 top push 3 pop push 4 pop What are the elements and their counts in the max cache after all the above operations? 6. Queue (15 points) Suppose we are using array-based queue to solve Josephus problem (suppose we have 10 people and every 4th person is removed). What the queue will look like after we remove two people? 7. Fibonacci (12 points) Suppose we define a number sequence L as follows: when n 3, L(n) = L(n-1) + L(n-3) Write an efficient algorithm with no recursion to calculate the number sequence L(n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
