The Gateway to Computer Science Excellence
0 votes
61 views

5. 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

in DS by Junior (761 points) | 61 views

1 Answer

0 votes
BST->4

Stack->10

Queue->20

I'm not sure about queue. Can anyone check it?
by (139 points)
0
i think queue is also 10??

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,587 answers
195,788 comments
101,841 users