Algorithm to insert an element in a circular queue.

Assuming that the circular queue is stored in QU with size N.

Check if Queue already filled or not

Step 1.if (FRONT = 1 and REAR = N) or (FRONT = REAR + 1) then
{
write "Overflow !!"
}
else
{

Step 2.if FRONT = NULL then
{
set FRONT = 1
REAR = 1
}

Step 3.else if REAR = N then
set REAR = 1
else

Step 4.set REAR = REAR + 1
}
// end of if

Step 5.set QU[REAR] = I_ITEM  // (to insert the new item I_ITEM)

Step 6.return.

Read also:- Algorithm to delete an element in a circular queue

This is the algorithm to insert an element in a circular queue. If you have any query then tell me by commenting below.

Summary (सारांश)

Circular Queue में नया element इंसर्ट करने की प्रक्रिया को समझने के लिए यह लेख बहुत उपयोगी है। कंप्यूटर साइंस के छात्रों के लिए Data Structure विषय के अंतर्गत Queue और Circular Queue के concepts को clear करना बेहद जरूरी होता है। इस article में आपको Algorithm to insert an element in a circular queue की पूरी स्टेप-बाय-स्टेप प्रक्रिया आसान भाषा में सीखने को मिलेगी। इस लेख और PDF नोट्स की मदद से आप सीखेंगे कि:

  • Circular Queue में Overflow condition की जांच कैसे की जाती है।
  • FRONT और REAR pointers को कैसे मैनेज किया जाता है।
  • नए item को सही इंडेक्स पर कैसे इंसर्ट करते हैं।
  • Memory optimization के लिए circular nature का उपयोग कैसे होता है।
यदि आप B.Tech, BCA, MCA या किसी अन्य Computer Science course की तैयारी कर रहे हैं, तो यह टॉपिक आपके Semester Exams और Coding Interviews के लिए बहुत महत्वपूर्ण है। इस algorithm को सही तरीके से समझकर आप programming में Circular Queue से जुड़े सवालों को आसानी से हल कर पाएंगे।

Leave a Comment