By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,905 Members | 879 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,905 IT Pros & Developers. It's quick & easy.

Queue using array

P: 60
i've implemented a linear Queue using array.
But i've been struck up with a doubt!!!!!

Let me tell my problem with an example so that it can be clear.

Size of the Queue(array) is 5.
im initializing the front and rear to 0.
I continously add five elements to the Queue, so that now the rear points to the 4th position of the array and now the queue is full.
Now i delete all the five elements and now the Front and the Rear points at the 4th position of the array.
My problem starts here.
Now the Queue is empty. Whether i've to reset the position of rear and front to 0 or not?
Mar 14 '07 #1
Share this Question
Share on Google+
2 Replies

P: 1,806
If the Queue is empty, then it probably doesn't matter which element you are pointing at, as long as the algorithm is well implemented.
As a point of functionality, however, I think that the pointer should point to the first (0th) element of the array, as a delete operations should probably move to the next element....
That is, if you have three elements and delete 2, you would want to point to the remaining (third) element. Likewise if you have 5 elements and delete all 5, you want to point to the NEXT (6th) element, which in this case would be the first...
Mar 14 '07 #2

P: 60
thank you for your help.
Mar 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.