0% found this document useful (0 votes)
3 views1 page

7 Alog

Uploaded by

nn4489
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

7 Alog

Uploaded by

nn4489
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Initialization: Set front to 0, rear to -1, and size to 0.

These variables manage


the current state of the queue.

Check if Empty: The queue is empty if size is 0.

Check if Full: The queue is full if size equals the maximum size of the array
(MAX).

Enqueue Operation:

Verify if the queue is full.


Increment rear (wrap around using modulo operation if necessary).
Insert the element at rear index in the array.
Increment size.
Dequeue Operation:

Verify if the queue is empty.


Retrieve the element at the front index from the array.
Increment front (wrap around using modulo operation if necessary).
Decrease size.
Front and Rear Access:

Front: Return the element at the front index.


Rear: Return the element at the rear index.
Print Queue:

Iterate through the queue from front to rear and print each element.

Pushed 10
Pushed 20
Pushed 30
Stack after pushes:
30
20
10
Top element: 30
Popped element: 30
Popped element: 20
Stack after pops:
10

You might also like