in DS edited by
313 views
1 vote
1 vote

Can someone explain the solution along with a picture of how the steps are taking place? 

in DS edited by
313 views

2 Comments

Is it _ abc_ ?
1
1
Yes it is _abc_ correct @minipanda
1
1

1 Answer

2 votes
2 votes
initially, p _ _ q r ;

where front pointer point to q and rear pointer point to p;

1. enqueue 'a'    -->    p a _ q r

2. dequeue        -->    p a _ _ r

3. enqueue 'b'    -->    p a b _ r

4. dequeue        -->    p a b  _ _

5. enqueue 'c'    -->    p a b c _  

6. dequeue        -->    _ a  b c _