The Gateway to Computer Science Excellence
0 votes
586 views

Suppose a dequeue is stored in a circular array with N memory cells. At which of the following condition is the dequeue is full? 


(i) LEFT = N and RIGHT = 1 
(ii) LEFT = RIGHT + 1 
(iii) LEFT = 1 and RIGHT = N 
(iv) LEFT = RIGHT - 1 + N

  1. (i) and (iii)
  2. (iii) and (iv)
  3. (ii) and (iii)
  4. (i) and (iv)
in DS by Loyal (5.2k points) | 586 views
0
what is Rear pointer in your view ?

is ar[rear] = new element or ar[rear+1] = new element ? which convention you are following ?
0
Nothing is mentioned in the Question so

1. i think we have to check both possibility i.e Left =front/Rear.

2. As its circular array  we should go with ar[rear+1]=new.
0
then option c is good choice !
0
Yes C is the given ans.

please explain ii i think this condition can be fulfilled though there is space in array(after deletion).
+1
let think there are 5 slots in array index 1-5 !

after inserting 4 elements, you deleted 3 elements,

Now left ( used as front pointer ), points to arr[4]

again insert 4 elements, right ( used as rear pointer ) is points at arr[3].

Now for inserting one more element, arr[right+1] == Left, which indicates it is FULL.

PS :- we have to use mod technique, to rotate indices in loop !
0

@Shaik Masthan

what is meaning of left =N and right=1

means rear contains N elements and front 1 element?

0
left means, front pointer position and right means rear pointer position
0
then why front=1?

It means front always contain 1 element in the circular array?
0
no, it means at particular time, front = 1 and rear=N, indicates queue is full !

Please log in or register to answer this question.

No related questions found

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,297 answers
198,262 comments
104,976 users