2. DEFINITION
• Queue is a linear data structure where elements are ordered
in special fashion.
i.e. FIFO(First IN First Out). Which means element inserted first
to the queue will be removed first from the queue.
In other words: queue is a list or collection with the restriction
or constraints that insertion can be performed at one end (rear
or tail) and deletion can be performed at other end(front or
head)
Author:Tusifu Edison
3. ROLE OF THE QUEUES
Queue is most often used in a scenario where there is a
shared resource that’s supposed to serve some request but
the resource can handle only one request at a time.
A machine has a processor to process different
programs(or to execute all instructions), and it has the
ability to process one program at a time, so the processes
are put in the queue.
For the front process to be terminated
Author:Tusifu Edison
4. IMPLEMENTING QUEUES WITH LINKED
LIST VS ARRAY
Main disadvantages of implementing queues with arrays
And linked list is the solution
• By using array list you may store large memory which you will
not use,
• The array may get filled when you have other elements you
want to insert
That will cause to stop the insertion or create another big array
and copy the first array
And add the elements which you wantAuthor:Tusifu Edison
5. OPERATIONS AVAILABLE WITH QUEUE
• EnQueue(x) or push (x):insertion of element at the the rear or
the tail of the queue.
• Dequeue() or pop():deletion the element from the front or
head of the queue.
• Front() or peek():to look the element at the front
• Is empty():check if the queue is empty or not
Example:
NB: all of this operations has the constant time or O(1)
Author:Tusifu Edison