search
Log In
0 votes
112 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 112 views

1 Answer

0 votes
BST->4

Stack->10

Queue->20

I'm not sure about queue. Can anyone check it?
0
i think queue is also 10??

Related questions

0 votes
1 answer
1
172 views
What are the minimum number of pointers required to implement a stack using single ended queue ( the queue is NOT a dequeue )?
asked Jul 26, 2018 in DS kapilbk1996 172 views
0 votes
1 answer
2
244 views
Consider implementation of stack using queue by following algorithm. Let $x$ be an element to be pushed in the stack push(q1,x) { EQ(q1,x) while(q1 does not contain 1 element) { k=DQ(q1) EQ(q1,k) } } pop(q1) { DQ(q1) } How many enqueue and dequeue operations required to push $2$ and pop $2$ elements in the empty stack?
asked Apr 30, 2018 in DS himgta 244 views
0 votes
2 answers
3
272 views
A queue is implemented using two stacks S1 and S2. Initially the queue contains 1, 2, 3, 4 from front to rear. The following operations are performed in the queue: delete, insert (5), delete, Then how many total no. of push and pop operations are needed to perform the above operation? a) Push: 12 Pop: 13 b) Push: 15 Pop: 16 c) Push: 11 Pop: 10 d) Push: 12 Pop: 11
asked Jan 31, 2018 in DS Tuhin Dutta 272 views
...