Learn Queue in Data Structure – TCCICOMPUTERCOACHING.COM

Queue is very important in Data Structure, before learning Queue, first of all we have to learn what Data Structure is?

In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Data structures can implement one or more particular abstract data types (ADT), which specify the operations that can be performed on a data structure and the computational complexity of those operations.

A queue is a container of objects (a linear collection) that are inserted and removed according to the first-in first-out (FIFO) principle. An excellent example of a queue is a line of students in the food court of the UC. New additions to a line made to the back of the queue, while removal (or serving) happens in the front. In the queue only two operations are allowed enqueue and dequeue. Enqueue means to insert an item into the back of the queue, dequeue means removing the front item. The picture demonstrates the FIFO access.

The difference between stacks and queues is in removing. In a stack we remove the item the most recently added; in a queue, we remove the item the least recently added.

Characteristics of Queue:

Like Stack, Queue is also an ordered list of elements of similar data types.

Queue is a FIFO (First in First Out) structure.

Once a new element is inserted into the Queue, all the elements inserted before the new element in the queue must be removed, to remove the new element.

Peek ( ) function is often used to return the value of first element without dequeuing it.

Applications of Queue:

Queue, as the name suggests is used whenever we need to have any group of objects in an order in which the first one coming in, also gets out first while the others wait for their turn, like in the following scenarios:

Serving requests on a single shared resource, like a printer, CPU task scheduling etc.

In real life, Call Centre phone systems will use Queues, to hold people calling them in an order, until a service representative is free.

Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive, First come first served.

Queue can be implemented using an Array, Stack or Linked List. The easiest way of implementing a queue is by using an Array.

If you like this post then please share and like this post.

Visit us @ tccicomputercoaching.com.

Call us @ 98256 18292.

To Learn More About Data structure at Ahmedabad, Data structure course

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s