Assuming that the Circular queue is stored in as array QU with size N.
This algorithm will delete an element from the circular queue and assign it to D-ITEM.
[Checking if QU is already empty or not?]
1. if FRONT = NULL then
{
write "Underflow !!"
return
}
else
{
2. set D_ITEM = QU [FRONT]
[Now Making FRONT point to the next element in the queue]
3. if FRONT = REAR then
{
FRONT = NULL
REAR = NULL
}
4. else if FRONT = N then
FRONT = 1
else
5. FRONT = FRONT + 1
6. return
Read Also:- Algorithm to insert an element in a circular queue
This is the Algorithm to Delete an Element from a Circular Queue. If you have any questions then comment below.
Summary (सारांश)
Circular Queue से किसी Element को Delete करने की प्रक्रिया को समझने के लिए यह लेख बहुत उपयोगी है। इस लेख में Array के रूप में स्टोर Circular Queue से डेटा हटाने के Algorithm को बहुत ही आसान भाषा में समझाया गया है। इस लेख को पढ़ने के बाद छात्र निम्नलिखित बातें सीखेंगे:
- Circular Queue में Underflow की स्थिति की पहचान कैसे की जाती है।
- FRONT और REAR pointers को update करने का सही तरीका क्या है।
- जब Queue में केवल एक ही Element बचा हो, तब Queue को खाली कैसे किया जाता है।
- Array की सीमा (Size N) समाप्त होने पर FRONT को वापस पहले Index पर कैसे लाया जाता है।