Meloi M. Magpantay It2A: Unleashin
Meloi M. Magpantay It2A: Unleashin
2.0
U n le a s h in
Meloi M. Magpantay
IT2A
Push adds items to the stack and pop Enqueue adds items to the rear and
removes recently added items from the dequeue removes items from the front of
stack the queue
Only one pointer is used in a stack Two pointers are used in simple queue
case
Array
We can easily represent queue by using linear arrays. There are two variables
i.e. front and rear, that are implemented in the case of every queue. Front and rear
variables point to the position from where insertions and deletions are performed in a
queue. Initially, the value of front and queue is -1 which represents an empty queue.
CI TE
2.0
U n le a s h in
Array representation of a queue containing 5 elements along with the respective values
of front and rear, is shown in the following figure.
The above figure shows the queue of characters forming the English word
"HELLO". Since, No deletion is performed in the queue till now, therefore the value of
front remains -1 . However, the value of rear increases by one every time an insertion is
performed in the queue. After inserting an element into the queue shown in the above
figure, the queue will look something like following. The value of rear will become 5
while the value of front remains same.
After deleting an element, the value of front will increase from -1 to 0. however,
the queue will look something like following.
CI TE
2.0
U n le a s h in
Linked List
In a linked queue, each node of the queue consists of two parts i.e. data part and
the link part. Each element of the queue points to its immediate next element in the
memory.
In the linked queue, there are two pointers maintained in the memory i.e. front
pointer and rear pointer. The front pointer contains the address of the starting element
of the queue while the rear pointer contains the address of the last element of the
queue.
Insertion and deletions are performed at rear and front end respectively. If front
and rear both are NULL, it indicates that the queue is empty.
The linked representation of queue is shown in the following figure.
CI TE
2.0
U n le a s h in
Simple queue lets us perform the operations simply. i.e., the insertion and
deletions are performed likewise. Insertion occurs at the rear (end) of the queue and
deletions are performed at the front (beginning) of the queue list.
All nodes are connected to each other in a sequential manner. The pointer of the
first node points to the value of the second and so on.
The first node has no pointer pointing towards it whereas the last node has no
pointer pointing out from it.
Circular Queue
In a circular queue each node is connected to the next node in sequence but the
last node’s pointer is also connected to the first node’s address. Hence, the last node
and the first node also gets connected making a circular link overall.
CI TE
2.0
U n le a s h in
Priority Queue
Priority queue makes data retrieval possible only through a pre determined
priority number assigned to the data items.
While the deletion is performed in accordance to priority number (the data item
with highest priority is removed first), insertion is performed only in the order.
2.0
U n le a s h in
The doubly ended queue or dequeue allows the insert and delete operations
from both ends (front and rear) of the queue.
Queues are an important concept of the data structures and understanding their
types is very necessary for working appropriately with them.
2.0
U n le a s h in
References:
https://www.geeksforgeeks.org/queue-data-structure/
CI TE
2.0
U n le a s h in
https://www.google.com/search?
q=similarities+and+differences+of+queues+and+stacks&tbm=isch&source=iu&ictx=1&fi
r=XpR-UuXteam9gM%253A%252CfGFZCb3cc9XqYM%252C_&vet=1&usg=AI4_-
kQUDYUJdlAiJt7JO_c9tla18LIoRQ&sa=X&ved=2ahUKEwjSor3FkPXlAhUFy4sBHarOC
LwQ9QEwAHoECAUQAw#imgrc=XpR-UuXteam9gM:
https://www.google.com/search?
q=similarities+and+differences+of+queues+and+stacks&oq=similarities+and+difference
s+of+queues+and+stacks&aqs=chrome..69i57j0l2.11736j1j7&sourceid=chrome&ie=UT
F-8
https://www.javatpoint.com/array-representation-of-queue
https://www.geeksforgeeks.org/queue-linked-list-implementation/
https://www.thecrazyprogrammer.com/2019/01/types-of-queues-in-data-structure.html
https://www.quora.com/What-are-the-applications-of-queues
https://www.quora.com/What-are-the-various-operations-in-a-queue-Can-you-explain-
each-of-them
https://www.tutorialspoint.com/data_structures_algorithms/dsa_queue.htm