What is the relationship between a queue and its underlying array?

Skill/Topic: Queue
A) Data stored in a queue is actually stored in an array. The queue tracks which array element is at the front of the queue and which array element is at the back of the queue.

Showing Answers 1 - 4 of 4 Answers

samiksc

  • Jan 19th, 2006
 

A queue's elements may be stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.

When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.

When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

  Was this answer useful?  Yes

Franklin Fujimori

  • Jul 8th, 2014
 

A queues elements may be stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.

When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.

When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions