edited by
24,771 views
54 votes
54 votes

Suppose a stack implementation supports an instruction $\text{REVERSE}$, which reverses the order of elements on the stack, in addition to the $\text{PUSH}$ and $\text{POP}$ instructions. Which one of the following statements is $\text{TRUE}$ (with respect to this modified stack)?

  1. A queue cannot be implemented using this stack.
  2. A queue can be implemented where $\text{ENQUEUE}$ takes a single instruction and $\text{DEQUEUE}$ takes a sequence of two instructions.
  3. A queue can be implemented where $\text{ENQUEUE}$ takes a sequence of three instructions and $\text{DEQUEUE}$ takes a single instruction.
  4. A queue can be implemented where both $\text{ENQUEUE}$ and $\text{DEQUEUE}$ take a single instruction each.
edited by

9 Answers

Answer:

Related questions

21 votes
21 votes
1 answer
1
go_editor asked Sep 28, 2014
5,565 views
A priority queue is implemented as a Max-Heap. Initially, it has $5$ elements. The level-order traversal of the heap is: $10, 8, 5, 3, 2$. Two new elements $1$ and $7$ ar...
25 votes
25 votes
3 answers
2
go_editor asked Sep 28, 2014
9,905 views
The number of distinct positive integral factors of $2014$ is _____________
34 votes
34 votes
3 answers
4
go_editor asked Sep 28, 2014
11,244 views
Which of the following socket API functions converts an unconnected active TCP socket into a passive socket?$\textsf{connect}$$\textsf{bind}$$\textsf{listen}$$\textsf{acc...