Transactions
November 6, 2023
Question 1084 – Nielit Scientist-B CS 22-07-2017
November 6, 2023
Transactions
November 6, 2023
Question 1084 – Nielit Scientist-B CS 22-07-2017
November 6, 2023

Data-Structures

Question 6

A queue Q containing n items and an empty stack S are given. It is required to transfer all the items from the queue to the stack, so that the item at the front of queue is on the top of the stack, and the order of all other items is preserved.
Show how this can be done in O(n) time using only a constant amount of additional storage. Note that the only operations which can be performed on the queue and stack are Delete, Insert, Push and Pop. Do not assume any implementation of the queue or stack.

A
Theory Explanation.
Correct Answer: A
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!