Transactions
November 6, 2023Question 1084 – Nielit Scientist-B CS 22-07-2017
November 6, 2023Data-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.
Theory Explanation.
|
Correct Answer: A
Subscribe
Login
0 Comments