Question 1987 – KVS 22-12-2018 Part-B
May 22, 2024Question 6861 – Data-Structures
May 23, 2024Question 16900 – Data-Structures
Consider a sequence a of elements a0 = 1, a1 = 5, a2 = 7, a3 = 8, a4 = 9, and a5 = 2. The following operations are performed on a stack S and a queue Q, both of which are initially empty.
I: push the elements of a from a0 to a5 in that order into S.
II: enqueue the elements of a from a0 to a5 in that order into Q.
III: pop an element from S.
IV: dequeue an element from Q.
V: pop an element from S.
VI: dequeue an element from Q.
VII: dequeue an element from Q and push the same element into S.
VIII: Repeat operation
VII three times. IX: pop an element from S. X: pop an element from S.
The top element of S after executing the above operations is _____?
Correct Answer: A
Question 221 Explanation:
Given the sequence “a” of elements a0 = 1, a1 = 5, a2 = 7, a3 = 8, a4 = 9, and a5 = 2.
I: push the elements from a0 to a5 in that order into S.
II: enqueue the elements of a from a0 to a5 in that order into Q.
III: pop an element from S.
IV: dequeue an element from Q.
V: pop an element from S.
VI: dequeue an element from Q.
VII: dequeue an element from Q and push the same element into S.
Element “7” is deleted and inserted into stack “S”
VIII: Repeat operation VII three times.
After performing the VIII operation , the elements of stack are as shown below
IX: pop an element from S.
X: pop an element from S
The top element of S after executing the above operations is 8.
I: push the elements from a0 to a5 in that order into S.
II: enqueue the elements of a from a0 to a5 in that order into Q.
III: pop an element from S.
IV: dequeue an element from Q.
V: pop an element from S.
VI: dequeue an element from Q.
VII: dequeue an element from Q and push the same element into S.
Element “7” is deleted and inserted into stack “S”
VIII: Repeat operation VII three times.
After performing the VIII operation , the elements of stack are as shown below
IX: pop an element from S.
X: pop an element from S
The top element of S after executing the above operations is 8.
8
Subscribe
Login
0 Comments