recategorized by
389 views
0 votes
0 votes

The initial configuration of quaue is $a, b, c, d$. $'a'$ is at the front. To get the configuration $d, c, b, a$ how many deletions and additions required:

  1. $2$ deletions, $3$ additions
  2. $3$ deletions, $2$ additions
  3. $3$ deletions, $4$ additions
  4. $3$ deletions, $3$ additions
recategorized by

1 Answer

0 votes
0 votes

To perform insertion and deletion in queue we have 2 variable called $\text{Front, Rear.}$

  1. Front:  Front is a variable which contain position of element to be deleted.
  2. Rear: Rear is a variable which contain position of element to be inserted.

Now according to the current queue: 

$a$ (front) $b$ $c$ $d$

Delete $a$:

$-$ $b$ (front) $c$ $d$

Delete $b$:

$-$ $-$ $c$(front) $d$

Delete $c$:

$-$ $-$ $-$ $d$ (front,rear)

 

to achieve $d,c,b,a$ we have to perform 3 insertion;

Insert $c$:

$d$ (front) $c$ (Rear)

Insert $b$:

$d$(front) $c$ $b$(rear)

insert $a$:

$d$(front) $c$ $b$ $a$(rear)

To get configuration $d,c,b,a$ we required $3$ deletion and $3$ insertion operation.

So option $D$ is correct. 

 

Related questions

0 votes
0 votes
1 answer
1
go_editor asked Mar 27, 2020
457 views
Which of the following is not collision Resolution Technique :Hash addressingChainningIndexingNone of these
0 votes
0 votes
2 answers
2
go_editor asked Mar 27, 2020
248 views
A hash function $f$ defined as $f(\text{key}) =\text{key mod}$ $7$, with linear probing it is used to insert the key $37,38,72,48,98,11,56$ into a table index from $0$ to...
0 votes
0 votes
1 answer
3
go_editor asked Mar 27, 2020
333 views
Which traversal techniques lists the nodes of a binary search tree in ascending order?post – orderin – orderpre – orderlinear – order