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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!