edited by
636 views
1 votes
1 votes

The initial configuration of a queue is a, b, c, d (a is in the front). To get the configuration d ,c, b, a, we need minimum number of:

  1. $2$ deletions & $3$ additions
  2. $3$ deletions & $2$ additions
  3. $3$ deletions & $3$ additions
  4. $3$ deletions & $4$ additions
edited by

1 Answer

Best answer
1 votes
1 votes
The elements of queue are meant to be reversed and we know queue follows FIFO(first in first out) so according to this rule...
abcd ..a will be deleted then b and then c...
d will be left in queue
then c will be added - dc
then b will be added -dcb
then a will be added - dcba
so total no. of deletions and insertions will be 3 and 3 respectively
selected by
Answer:

Related questions

0 votes
0 votes
1 answer
2
Bikram asked Nov 26, 2016
1,637 views
Three algorithms do the same task. Algorithm One is $O(N)$ and Algorithm Two is $O(\log N)$ and Algorithm Three is $O(N1/2)$. Which algorithm should execute the fastest f...
1 votes
1 votes
3 answers
3
0 votes
0 votes
0 answers
4