answersLogoWhite

0


Best Answer

A queue is a first-in, first-out (FIFO) structure. This means insertions occur at the end of the data sequence while extractions occur at the beginning of the sequence. Array-based queues are problematic for two reasons.

Inserting at the end of a sequence is fine when there are unused elements available (which you must keep track of), but when the queue is full the array must be resized in order to free up more unused elements. If there is insufficient memory to expand into the entire array must be reallocated to new memory which means the entire array must be copied. Copying arrays is an expensive operation as every element must be copied individually. An array of pointers (or resource handles with move semantics) rather than an array of objects would improve efficiency but for the duration of the copy process you will be consuming more than twice as much memory; one block for the original queue and another larger block for the new allocation.

However, the biggest problem is what to do when elements are extracted from the front. This will mean you have an unused element at the beginning of the array and the only way to eliminate it is by shunting all elements forward by one and that means copying them (again, pointers or resource handles would be more efficient). A better approach is to use a circular array such that you keep track of the unused elements at both the beginning and end of the sequence.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the problem of an array based queue?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Queue ADT Using Array?

implement the queue ADT using an array


Which queue most efficient queue using array?

circular queue


What is the difference between queues and circular queues?

A queue can use a dynamic array, or a linked list, but if using static memory, the queue becomes a circular queue because the underlaying data structure is a static circular array. This means the ends of the array are attached.


Array implementation of priority queue?

the priority queue is which depends on the data stored.in which their priority is maintained by checking the forth coming values stored in the queue


What is single dimension in data structure?

Array, Stake, Queue.


Write down the function to insert an element into a queue, in which the queue is implemented as an array?

bring the police they will be in que by themselves


Algorithm to implement Multiple queue in single dimensional array?

algorithm on multiple queues in a single dimensional array


How do you implement a FIFO structure?

FIFO is a first-in, first out structure. In other words, it is a queue. The most efficient way to implement a queue is with a circular array.


What are types of Queue?

Queue is a data structure which is based on FIFO that is first in first out. Following are the types of queue: Linear queue Circular queue Priority queue Double ended queue ( or deque )


Array implementation of priority queue example program in c plus plus?

yes


Data structure algorithms using C?

array,linklist,queue,stack,tree,graph etc...


What are the various operations that can be performed on a queue?

In queue insertion takes place on rear end and deletion takes place on front end. INSERTION(QUEUE,N,FRONT,REAR,ITEM) :QUEUE is the name of a array on which we are implementing the queue having size N. view comlete ans at http://mcabcanotes.in/algorithm-to-perform-insertion-and-deletion-in-a-queue/