Download presentation
Presentation is loading. Please wait.
1
Philip Bernhard, PhD Spring 2018
CSE 1002 Fundamentals of Software Development 2 Exercises on Stacks, Queues and BSTs Philip Bernhard, PhD Spring 2018
2
Simulating Stacks, Queues and BSTs
Suppose you had two stacks A and B, and a queue C, that are all initially empty. Show the contents of A, B, and C, after the following operations are performed…
3
Simulating Stacks, Queues and BSTs
Push(5,A) Push(17,A) Push(4,B) Push(3,A) Push(10,A) Push(8,B) Enqueue(4,C) Enqueue(65,C) X = pop(A) Enqueue(X,C) Y = peek(B) Enqueue(Y,C) Z = Dequeue(C) Push(Z,A) Enqueue(Z,C) Y = pop(B) Push(Z,B)
4
Simulating Stacks, Queues and BSTs
What if a BST and associated operations are added to the mix?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.