Operations on a Queue
The basic operations that can be performed on queue are;
1. To insert an element in a queue. 2. To delete an element from the queue.
ALGORITHMS FOR INSERTION AND DELETION IN QUEUE
Let Queue be the array of some specified size say MAXSIZE, then the insertion algorithm will be as given below. While implementing a queue using array we must check underflow and overflow conditions for queue.
Algorithm for Addition in a Queue
QINSERT (MAXSIZE, ITEM)
1. Initialize Front = 0 and Rear = - 1
2. If Rear >= MAXSIZE [check overflow condition]
Print Queue overflow and return
Else;
Set Rear = Rear + 1
3. Queue [rear] = item
4. If Front = -1 [set the front pointer]
5. Return.
Algorithm for Deletion from a Queue
QDELETE (MAXSIZE, TIEM)
1. If front < 0 [check underflow condition]
Print Queue is Empty and return
2. Else : item = Queue [front] [Remove Element From Front]
3. Find new value of front.
If (front = Rear) [checking For Empty Queue]
Set Front = 0, Rear = -1 [Re-initialize the pointers]
Else:
Front = Front + 1
Data Structure & Algorithms Assignment Help, Live Experts
Struggling with data structure problems? Data structure subject is quite tough to learn? Need quick assistance in data structure questions? ExpertsMind.com is right place for you where your search ends, We at ExpertsMind offer online data structure assignment help, data structure homework help and data structure and algorithms question's answers by best online support by qualified tutors.
ExpertsMind.com - Operations on a Queue Assignment Help, Operations on a Queue Homework Help, Operations on a Queue Assignment Tutors, Operations on a Queue Solutions, Operations on a Queue Answers, Queues Assignment Tutors