ARRAY IMPLEMENTATION OF QUEUES Using C++
ARRAY IMPLEMENTATION OF QUEUES Using rear and front. It is a linear data structure and it follows the first in first out technique. Using C++ Programming Language.
Definition:
ARRAY IMPLEMENTATION OF QUEUES Using rear and front.
ALGORITHM:
Enqueue
- Start
- If the stack is empty, then read the data
- Increment the rear and store the data in the rear index of q
- Stop
Dequeue
- Start
- Set the element to be deleted as q[front]
- Increment front
- Stop
Is empty
- Start
- If the rear is less than the front then return 1
- Otherwise, return 0
- Stop
Is full
- If the rear is equal to one less than the size then return 1
- Otherwise, return 0
- Stop
Display
- Start
- From front as the first index and rear as the last index print all the elements
- Stop
For Example:
Enter choice
Menu...
1.Insert
2.Delete
3.Display
1
Enter the data 2
Do you want to continue (0/1) 1
Enter choice
Menu...
1.Insert
2.Delete
3.Display
1
Enter the data 3
Do you want to continue (0/1) 1
Enter choice
Menu...
1.Insert
2.Delete
3.Display
3
Displaying...
2 3
Do you want to continue (0/1 )1
Enter choice
Menu...
1.Insert
2.Delete
3.Display
2
Displaying...
3
Do you want to continue (0/1) 0
NOTE:
In a queue, the element is inserted on the rear side and deleted on the front side.
Project Files
| .. | ||
| This directory is empty. | ||