The power point presentation shows the Implementation of Queue operations using arrays and Linked List. Further, It also demonstrates about Circular queue operations.
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
Insert works in constant time for either end of a linked list. Remove works in constant time only. Seems best that head of the linked list be the front of the queue so that all removes will be from the front. Inserts will be at the end of the list
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueBalwant Gorad
Explain Stack and its Concepts, Its Operations, Queue, Circular Queue, Priority Queue. Explain Queue and It's Operations
Data Structures, Abstract Data Types
Queues
a. Concept and Definition
b. Queue as an ADT
c. Implementation of Insert and Delete operation of:
• Linear Queue
• Circular Queue
For More:
https://github.com/ashim888/dataStructureAndAlgorithm
http://www.ashimlamichhane.com.np/
LINEAR QUEUE with Diagram and C implementation.
Operations of LINEAR QUEUE
Drawback of LINEAR QUEUE
CIRCULAR QUEUE with Diagram and C implementation
Operations of CIRCULAR QUEUE
PRIORITY QUEUE with Diagram and C implementation
Operations of PRIORITY QUEUE
CASE STUDIES
EXAMPLES
Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
Insert works in constant time for either end of a linked list. Remove works in constant time only. Seems best that head of the linked list be the front of the queue so that all removes will be from the front. Inserts will be at the end of the list
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueBalwant Gorad
Explain Stack and its Concepts, Its Operations, Queue, Circular Queue, Priority Queue. Explain Queue and It's Operations
Data Structures, Abstract Data Types
Queues
a. Concept and Definition
b. Queue as an ADT
c. Implementation of Insert and Delete operation of:
• Linear Queue
• Circular Queue
For More:
https://github.com/ashim888/dataStructureAndAlgorithm
http://www.ashimlamichhane.com.np/
LINEAR QUEUE with Diagram and C implementation.
Operations of LINEAR QUEUE
Drawback of LINEAR QUEUE
CIRCULAR QUEUE with Diagram and C implementation
Operations of CIRCULAR QUEUE
PRIORITY QUEUE with Diagram and C implementation
Operations of PRIORITY QUEUE
CASE STUDIES
EXAMPLES
An ordered collection of items from which items may be deleted from one end called the front and into which items may be inserted from other end called rear is known as Queue.
It is a linear data structure.
It is called the First In First Out (FIFO) list. Since in queue, the first element will be the first element out.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2. Introduction to Queues
• A queue is an ordered collection of items where the addition of new items
happens at one end, called the “rear,” and the removal of existing items
occurs at the other end, commonly called the “front.”
• Queue: FIFO (Fist In First Out) : Enqueue and Dequeue, front, rear
• Stack: FILO or LIFO , Push and Pop, top
9. Maxsize=6, rear=4, front=-1
• Qinsert(item)
• 1.If (rear = maxsize-1 )
• print (“queue overflow”) and return
• 2.Else
• rear = rear + 1
• Queue [rear] = item
20 30 40 50 60
0 1 2 3 4 5
rear
front
Function call
Qinsert(item)
Rear=maxsize-1 Rear=rear+1 Queue[rear]=item
Qinsert(20) -1=5 ? F Rear=-1+1=0 Queue[0]=20
Qinsert(30) 0=5? F Rear= 0+1=1 Queue[1]=30
Qinsert(40) 1=5? F Rear= 1+1=2 Queue[2]=40
Qinsert(50) 2=5? F Rear= 2+1=3 Queue[3]=50
Qinsert(60) 3=5? F Rear= 3+1=4 Queue[4]=60
If section Else section
1
2
3
4
5
10. Maxsize=6, rear=5, front=-1
• Qinsert(item)
• 1.If (rear = maxsize-1 )
• print (“queue overflow”) and return
• 2.Else
• rear = rear + 1
• Queue [rear] = item
20 30 40 50 60 70
0 1 2 3 4 5
rear
front
Function call
Qinsert(item)
Rear=maxsize-1 Rear=rear+1 Queue[rear]=item
Qinsert(20) -1=5 ? F Rear=-1+1=0 Queue[0]=20
Qinsert(30) 0=5? F Rear= 0+1=1 Queue[1]=30
Qinsert(40) 1=5? F Rear= 1+1=2 Queue[2]=40
Qinsert(50) 2=5? F Rear= 2+1=3 Queue[3]=50
Qinsert(60) 3=5? F Rear= 3+1=4 Queue[4]=60
Qinsert(70) 4=5? F Rear= 4+1=5 Queue[5]=70
If section Else section
1
2
3
4
5
6
11. Maxsize=6, rear=5, front=-1
• Qinsert(item)
• 1.If (rear = maxsize-1 )
• print (“queue overflow”) and return
• 2.Else
• rear = rear + 1
• Queue [rear] = item
20 30 40 50 60 70
0 1 2 3 4 5
rear
front
Function call
Qinsert(item)
Rear=maxsize-1 Rear=rear+1 Queue[rear]=item
Qinsert(20) -1=5 ? F Rear=-1+1=0 Queue[0]=20
Qinsert(30) 0=5? F Rear= 0+1=1 Queue[1]=30
Qinsert(40) 1=5? F Rear= 1+1=2 Queue[2]=40
Qinsert(50) 2=5? F Rear= 2+1=3 Queue[3]=50
Qinsert(60) 3=5? F Rear= 3+1=4 Queue[4]=60
Qinsert(70) 4=5? F Rear= 4+1=5 Queue[5]=70
Qinsert(80) 5=5? T stop
If section Else section
1
2
3
4
5
6
7
12. Maxsize=6, front=-1
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
20 30 40 50 60 70
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
If section Else section
13. Maxsize=6, front=0
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
30 40 50 60 70
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
If section Else section
1
Item=20
14. Maxsize=6, front=1
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
40 50 60 70
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
Qdelete() 0 = 5 ? F front=0+1=1 item=Queue[1]
If section Else section
1
Item=30
2
15. Maxsize=6, front=2
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
50 60 70
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
Qdelete() 0 = 5 ? F front=0+1=1 item=Queue[1]
Qdelete() 1 = 5 ? F front=1+1=2 item=Queue[2]
If section Else section
1
Item=40
2
3
16. Maxsize=6, front=3
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
60 70
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
Qdelete() 0 = 5 ? F front=0+1=1 item=Queue[1]
Qdelete() 1 = 5 ? F front=1+1=2 item=Queue[2]
Qdelete() 2 = 5 ? F front=2+1=3 item=Queue[3]
If section Else section
1
Item=50
2
3
4
17. Maxsize=6, front=4
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
70
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
Qdelete() 0 = 5 ? F front=0+1=1 item=Queue[1]
Qdelete() 1 = 5 ? F front=1+1=2 item=Queue[2]
Qdelete() 2 = 5 ? F front=2+1=3 item=Queue[3]
Qdelete() 3 = 5 ? F front=3+1=4 item=Queue[4]
If section Else section
1
Item=60
2
3
4
5
18. Maxsize=6, front=5
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
Qdelete() 0 = 5 ? F front=0+1=1 item=Queue[1]
Qdelete() 1 = 5 ? F front=1+1=2 item=Queue[2]
Qdelete() 2 = 5 ? F front=2+1=3 item=Queue[3]
Qdelete() 3 = 5 ? F front=3+1=4 item=Queue[4]
Qdelete() 4= 5 ? F front=4+1=5 item=Queue[5]
If section Else section
1
Item=70
2
3
4
5
6
19. Maxsize=6, front=5
rear=5
• Qdelete()
• If (front =rear)
• print “queue empty” and return
• 2. Else
• Front = front + 1
• item = queue [front];
• Return item
0 1 2 3 4 5
rear
front
Function call
Qdelete()
front=rear Front=front+1 Item=Queeue[front]
Qdelete() -1 = 5 ? F front=-1+1=0 item=Queue[0]
Qdelete() 0 = 5 ? F front=0+1=1 item=Queue[1]
Qdelete() 1 = 5 ? F front=1+1=2 item=Queue[2]
Qdelete() 2 = 5 ? F front=2+1=3 item=Queue[3]
Qdelete() 3 = 5 ? F front=3+1=4 item=Queue[4]
Qdelete() 4= 5 ? F front=4+1=5 item=Queue[5]
Qdelete() 5=5? T queue empty - -
If section Else section
1
2
6
7
20. Conditions to be satisfied in Queue
• Queue is empty FRONT=REAR
• Queue is full REAR=Maxsize
• Queue contains element >= 1
FRONT <REAR
NO. OF ELEMENT = REAR-FRONT+1
Disadvantage of Queue: The deleted element’s space in the queuqe
cannot be reused-utilized for inserting another element.
24. Linked representation of Queues
290 Front 300 350 360 rear
9 300 7 350 4 360 2 380 5 N
290 front 300 350 360 380 rear
Linked queue after inserting a node
300 front 350 360 380
Linked queue after deleting a node
25. Insert an element in queue using linked list
STEP-1: Allocate memory for the new node & name it as TEMP.
STEP-2: SET TEMP➔ DATA = NUM
SET TEMP→ LINK = NULL
STEP-3: IF FRONT = NULL
FRONT=REAR=TEMP
ELSE
REAR→ LINK =TEMP
REAR=TEMP
[ END OF IF]
STEP-4: EXIT
FRONT=REAR=NULL
26. 20 NULL
5000
TEMP
STEP-1: Allocate memory for the new node & name it as TEMP.
STEP-2: SET TEMP➔ DATA = NUM
SET TEMP→ LINK = NULL FRONT=REAR=NULL
1. QINSERT_LINK(TEMP)
Data link
27. STEP-3: IF FRONT = NULL
FRONT=REAR=TEMP
ELSE
REAR→ LINK =TEMP
REAR=TEMP
[ END OF IF]
FRONT=REAR=5000
20 NULL
5000
FRONT REAR
28. 30 NULL
6000
TEMP
STEP-1: Allocate memory for the new node & name it as TEMP.
STEP-2: SET TEMP➔ DATA = NUM
SET TEMP→ LINK = NULL FRONT=REAR=TEMP
2. QINSERT_LINK(TEMP)
29. STEP-3: IF FRONT = NULL
FRONT=REAR=TEMP
ELSE
REAR→ LINK =TEMP
REAR=TEMP
[ END OF IF]
FRONT=5000
REAR=6000
20 NULL
5000
FRONT REAR
30 NULL
6000
TEMP
20 6000
5000
FRONT
REAR
30 NULL
6000
TEMP
30. 40 NULL
7000
TEMP
STEP-1: Allocate memory for the new node & name it as TEMP.
STEP-2: SET TEMP➔ DATA = NUM
SET TEMP→ LINK = NULL
3. QINSERT_LINK(TEMP)
FRONT=5000
REAR=6000
31. STEP-3: IF FRONT = NULL
FRONT=REAR=TEMP
ELSE
REAR→ LINK =TEMP
REAR=TEMP
[ END OF IF]
FRONT=5000
REAR=7000
20 6000
5000
FRONT REAR
30 NULL
6000
20 6000
5000
FRONT REAR
30 7000
6000
40 NULL
7000
TEMP
33. Delete an element in queue using linked list
STEP-1: If FRONT = NULL
write “underflow”
go to step 3.
[End of if]
STEP-2: SET TEMP = FRONT
FRONT=FRONT→ LINK
IF FRONT = NULL
REAR=NULL
STEP-3: EXIT
34. Delete an element in queue using linked list
STEP-1: If FRONT = NULL
write “underflow”
go to step 3.
[End of if]
STEP-2: SET TEMP = FRONT
FRONT=FRONT→ LINK
IF FRONT = NULL
REAR=NULL
STEP-3: EXIT
20 6000
5000
FRONT
REAR
30 7000
6000
40 NULL
7000
1. QDELETE_LINK()
TEMP
35. Delete an element in queue using linked list
STEP-1: If FRONT = NULL
write “underflow”
go to step 4.
[End of if]
STEP-2: SET TEMP = FRONT
FRONT=FRONT→ LINK
IF FRONT = NULL
REAR=NULL
STEP-3: FREE(TEMP)
STEP-4: EXIT
20 6000
5000
FRONT REAR
30 7000
6000
40 NULL
7000
1. QDELETE_LINK()
TEMP
FRONT REAR
30 7000
6000
40 NULL
7000
36. Delete an element in queue using linked list
STEP-1: If FRONT = NULL
write “underflow”
go to step 4.
[End of if]
STEP-2: SET TEMP = FRONT
FRONT=FRONT→ LINK
IF FRONT = NULL
REAR=NULL
STEP-3: FREE(TEMP)
STEP-4: EXIT
2. QDELETE_LINK()
TEMP
FRONT REAR
30 7000
6000
40 NULL
7000
TEMP
FRONT REAR
30 7000
6000
40 NULL
7000
FRONT REAR
40 NULL
7000
37. Delete an element in queue using linked list
STEP-1: If FRONT = NULL
write “underflow”
go to step 4.
[End of if]
STEP-2: SET TEMP = FRONT
FRONT=FRONT→ LINK
IF FRONT = NULL
REAR=NULL
STEP-3: FREE(TEMP)
STEP-4: EXIT
3. QDELETE_LINK()
4. QDELETE_LINK()
FRONT=NULL
REAR=NULL
40 NULL
7000
TEMP
FRONT REAR
40 NULL
7000
TEMP
TEMP
39. Dequeues
• Deque stands for double ended queue.
• Elements can be inserted or deleted at either end.
• Also known as head-tail linked list.
34 12 53 61 9
FRONT
Insertion
Deleion
REAR
Insertion
Deleion
40. Types of Dequeues
• Input restricted queue
34 12 53 61 9
FRONT
Deleion
REAR
Insertion
Deleion
41. Types of Dequeues
• Output restricted queue
34 12 53 61 9
FRONT
Deleion
REAR
Insertion
Insertion
42. Circular Queues
• Circular queue are used to remove the drawback of simple queue.
• Both the front and the rear pointers wrap around to the beginning of
the array.
• It is also called as “Ring buffer”.
43. Algorithm CQ_insert(ITEM)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
44. Algorithm CQ_insert(ITEM)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
FRONT=-1
REAR=-1
MAX=7
45. Algorithm CQ_insert(10)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=-1
REAR=-1
MAX=7
IF FRONT=-1 & REAR=-1 T
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(-1+1)%7=-1
0 = -1 F
C1
C2
REAR=(REAR+1)%MAX
FRONT=0
REAR=0
MAX=7
REAR=MAX-1 & FRONT!=0
REAR=0
C3
CQ[REAR]=ITEM
CQ[0]=10
46. Algorithm CQ_insert(20)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=0
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(0+1)%7= 0
1 = -1 F
C1
C2
REAR=(REAR+1)%MAX
(0+1)%7= 1
FRONT=0
REAR=1
MAX=7
REAR=MAX-1 & FRONT!=0
0=6 F & 0!0 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[1]=20
C4
20
47. Algorithm CQ_insert(30)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=1
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(1+1)%7= 0
2 = 0 F
C1
C2
REAR=(REAR+1)%MAX
(1+1)%7= 2
FRONT=0
REAR=2
MAX=7
REAR=MAX-1 & FRONT!=0
1=6 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[2]=30
C4
20
30
48. Algorithm CQ_insert(30)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=1
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(1+1)%7= 0
2 = 0 F
C1
C2
REAR=(REAR+1)%MAX
(1+1)%7= 2
FRONT=0
REAR=2
MAX=7
REAR=MAX-1 & FRONT!=0
1=6 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[2]=30
C4
20
30
49. Algorithm CQ_insert(40)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=2
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(2+1)%7= 0
3 = 0 F
C1
C2
REAR=(REAR+1)%MAX
(2+1)%7= 3
FRONT=0
REAR=3
MAX=7
REAR=MAX-1 & FRONT!=0
2=6 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[3]=40
C4
20
30
40
50. Algorithm CQ_insert(50)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=3
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(3+1)%7= 0
4= 0 F
C1
C2
REAR=(REAR+1)%MAX
(3+1)%7= 4
FRONT=0
REAR=4
MAX=7
REAR=MAX-1 & FRONT!=0
4=6 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[4]=50
C4
20
30
40
50
51. Algorithm CQ_insert(60)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=4
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(4+1)%7= 0
5= 0 F
C1
C2
REAR=(REAR+1)%MAX
(4+1)%7= 5
FRONT=0
REAR=5
MAX=7
REAR=MAX-1 & FRONT!=0
5=6 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[5]=60
C4
20
30
40
50
60
52. Algorithm CQ_insert(70)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=5
MAX=7
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(5+1)%7= 0
6= 0 F
C1
C2
REAR=(REAR+1)%MAX
(5+1)%7= 6
FRONT=0
REAR=6
MAX=7
REAR=MAX-1 & FRONT!=0
5=6 F
REAR=0
C3
CQ[REAR]=ITEM
CQ[6]=70
C4
20
30
40
50
60
70
53. Algorithm CQ_insert(80)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
10
FRONT=0
REAR=6
MAX=7
IF ((REAR+1)%MAX=FRONT)
(6+1)%7= 0
0= 0 T
C1
20
30
40
50
60
70
54. Algorithm CQ_insert(80)
• Step-1: If (REAR+1)%MAX=FRONT
• Write Overflow
• GoTo Step 4.
• [End of if]
• Step-2: If FRONT=-1 and REAR =-1
• REAR=FRONT=0
• Else If REAR=MAX-1 AND FRONT!=0
• REAR=0
• Else
• REAR=(REAR+1)%MAX
• [End of If]
• Step-3: CQ[REAR]=ITEM
• Step-4: Exit
CQ[0]
CQ[1]
CQ[2]
CQ[3]
CQ[4]
CQ[5]
CQ[6]
REAR
FRONT
IF FRONT=-1 & REAR=-1 F
REAR=FRONT=0
IF ((REAR+1)%MAX=FRONT)
(6+1)%7= 1
0= 1 F
C1
C2
REAR=(REAR+1)%MAX
FRONT=1
REAR=6
MAX=7
REAR=MAX-1 & FRONT!=0
6=6 T & 1!0 T
REAR=0
C3
CQ[REAR]=ITEM
CQ[0]=80
C4
20
30
40
50
60
70
CQ_delete()
80
55. Algorithm CQ_delete()
• Step-1: If FRONT=-1
• Write Underflow
• go to step 4
• [End of if]
• Step-2: VAL=CQ[FRONT]
• Step-3:If FRONT = REAR
• REAR=FRONT=-1
• Else If FRONT=MAX-1
• FRONT=0
• Else
• FRONT=FRONT+1
• [End of If]
• Step-4: Exit
CQ[0]
CQ[1]
CQ[3]
CQ[5]
CQ[6]
REAR
FRONT
10 20
30
40
50
60
CQ[2]
70