edited by
497 views
1 votes
1 votes
Assume I have a stack s, a queue q, and a binary search tree t. Initially all of them are empty. Indicate the state of the data structures at line number 7 and at the end. What is the maximum height each of the data structures had during the execution?

1 i  $\rightarrow$ 0
2 while i <= 9 do
3 q.put(2 .i)
4 s.push(2 .i + 1)
5 i  $\rightarrow$ i + 1
6 end
7 i  $\rightarrow$ 0
8 while i <= 9 do
9 t.insert(s.pop())
10 t.insert(q.get())
11 i $\rightarrow$  i + 1
12 end
edited by

1 Answer

0 votes
0 votes
BST->4

Stack->10

Queue->20

I'm not sure about queue. Can anyone check it?

Related questions

1 votes
1 votes
1 answer
1
amit166 asked Jan 6, 2019
1,378 views
How many enqueue and dequeue operations are required to perform a pop operation if Q1 contains n element initially?
0 votes
0 votes
1 answer
2
Souvik33 asked Nov 2, 2022
840 views
Which data structure would be most appropriate to implement a collection of values with the following 3 characteristicsSingly link list with head and tail pointerDoubly l...