Question: This time around, suppose D is a stack and the following numbers were added to D: 5, 12, 17, 3, 9, 7, 11, 15. That
This time around, suppose D is a stack and the following numbers were added to D: 5, 12, 17, 3, 9, 7, 11, 15. That is, 5 was added first, followed by 12, then 17, etc. We want to find the maximum number in D and used the algorithm described in the lecture:
While D.size LaTeX: \ge 2 x <- D.pop() y <- D.pop() D.push(max(x,y)) EndWhile Return D.pop The algorithm should return 17.
What was the very last number compared to 17?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
