in DS retagged by
474 views
4 votes
4 votes

Consider a circular array-based implementation of the queue where the front and rear has been initialized to $-1.$ Array size is $N.$
Which of the following statements is true for the number of elements or size of the queue?

  • $\text{S1:}$ if front $>$ rear then size $= N-$ front $+$ rear $+1$
  • $\text{S2:}$ If front $\leq$ rear then size $=$ rear $-$ front $+1$
  1. S1 is true but S2 is false
  2. S1 is false but S2 is true
  3. Both statements are true
  4. Both statements are false
in DS retagged by
474 views

1 comment

Corner Case 😐
3
3

2 Answers

9 votes
9 votes
$\text{S2}$ is false because when front $=$ rear $=-1$ then number of elements would be zero but $\text{S2}$ says $1.$

1 comment

In this question, can we use dry run approach?
0
0
1 vote
1 vote
Option A.) by “Udhay Brahmi”

 

edited by