The advantages of a queue in data structure

Written by stephen byron cooper Google
  • Share
  • Tweet
  • Share
  • Pin
  • Email
The advantages of a queue in data structure
Computers uses queues to process data arriving over the Internet. (Getty Thinkstock)

Storage structures for data fall into two categories: a queue and a stack. The difference between the two is the way they prioritise access to elements in the group. A queue brings out the first element entered into memory before all others. A stack brings out the last element entered into memory before all others.

Other People Are Reading

Order

The clear benefit of a queue is that it preserves data in the order in which it arrived. That is, it orders data by date and time, rather than any other criteria, like alphabetical, or size order. The fact that the first element in the queue is processed before all others means that a program can process live data in order of its entry. Thus if processing power is shared by several users, then each one has their data processed in turn, which is a fair way to share resources.

Buffering

A consequence of the queue’s ability to order data fairly means it is the ideal structure for a buffer. Buffers provide a holding space for incoming data when a process is not fast enough to cope with demand. The buffer is only useful if demand is variable. This is because it enables data to be delayed. At some point in the running cycle of the processor, demand should be lower enough to enable the process to work down the queue and empty it. Buffers reduce the likelihood of requests for services being denied because the processor is busy. Instead, requests arriving at peak times are delayed, rather than refused.

Arrays

Queue structures are commonly used for variables within programs. A typical structure for creating a queue is the array. This is structure of a series of elements that can be processed as a whole (like a “string”) or in order. An index gives access to each element in an array and this can be programmed into a loop with the index variable incrementing with each path. This method provides an easy method to order repetitive processing of data.

Implementations

Queues form the basis of a number of other structures used in data processing. One is a circular buffer, which is useful for processing an incoming stream of data. The circular buffer does not actually form a circle. Instead, it is a queue with a fill pointed and a read pointer and those pointers wrap back to the first element of the queue once they reach the last element. Thus, processing never ends. The queue is filled until it has no spaces left and then it overwrites the oldest element and continues overwriting elements in the order of their arrival. This type of queue is useful for processing multimedia data, where arriving data needs to be processed and then discarded. The sliding window method is also formed by a queue. This method makes several elements in the array available simultaneously. It then moves the window along one slot, eventually aging out the elements it has passed. This structure is commonly used to receive data over a network.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.