Presentation is loading. Please wait.

Presentation is loading. Please wait.

Philip Bernhard, PhD Spring 2018

Similar presentations


Presentation on theme: "Philip Bernhard, PhD Spring 2018"— Presentation transcript:

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?


Download ppt "Philip Bernhard, PhD Spring 2018"

Similar presentations


Ads by Google