9CM305.311 Name :B Vijaya kumari Designation : Lecturer Branch :Computer Engineering Institute :Smt.B.Seetha. Polytechnic, Bhimavaram, Year/semester :III.

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

Stacks, Queues, and Linked Lists
Queues and Linked Lists
1 Array-based Implementation An array Q of maximum size N Need to keep track the front and rear of the queue: f: index of the front object r: index immediately.
Data Structures Lecture 13: QUEUES Azhar Maqsood NUST Institute of Information Technology (NIIT)
COSC 1P03 Data Structures and Abstraction 9.1 The Queue Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find.
Stacks, Queues, and Deques. 2 A stack is a last in, first out (LIFO) data structure Items are removed from a stack in the reverse order from the way they.
Stacks  a data structure which stores data in a Last-in First-out manner (LIFO)  has a pointer called TOP  can be implemented by either Array or Linked.
Introduction to C Programming CE Lecture 12 Circular Queue and Priority Queue Data Structures.
 A queue is a waiting line…….  It’s in daily life:-  A line of persons waiting to check out at a supermarket.  A line of persons waiting.
Queues CS-212 Dick Steflik. Queues First In, First Out operation – FIFO As items are added they are chronologically ordered, items are removed in their.
ADT Queue 1. What is a Queue? 2. STL Queue 3. Array Implementation of Queue 4. Linked List Implementation of Queue 5. Priority Queue.
Fundamentals of Python: From First Programs Through Data Structures
1 Queues (5.2) CSE 2011 Winter May Announcements York Programming Contest Link also available from.
Queue RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
Department of Technical Education Andhra Pradesh
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
CS 206 Introduction to Computer Science II 10 / 20 / 2008 Instructor: Michael Eckmann.
Queue using an array. .head.tail Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they.
Queues.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation – FIFO As items are added they are chronologically ordered, items are removed.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Queue 1 Operations on Queues A Dequeue Operation An Enqueue Operation Array Implementation Link list Implementation Examples.
1 Stacks and Queues Based on D.S. Malik, Java Programming: Program Design Including Data Structures.
1 Name of the faculty: V. Narsimha Reddy Designation: Lecturer in EEE Branch : E.C.E. Institute : GMR. Polytechnic Gajwel Year / Semester : VI Semester.
1 Department of Technical Education Andhra Pradesh Name: V. Narsimha Reddy Designation: Lecturer in EEE Branch : D.E.C.E. Institute : GMR. Polytechnic.
Department of Technical Education Andhra Pradesh
Stacks And Queues Chapter 18.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Scis.regis.edu ● CS-362: Data Structures Week 8 Dr. Jesús Borrego 1.
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
Implementation of QUEUE For more notes and topics visit: eITnotes.com.
Department of Technical Education
Queue 09/10/081. Queue (Linear Queue) It is a linear data structure consisting of list of items. In queue, data elements are added at one end, called.
CHP-4 QUEUE. 1.INTRODUCTION  A queue is a linear list in which elements can be added at one end and elements can be removed only at other end.  That.
Department of Technical Education Andhra Pradesh
CE 221 Data Structures and Algorithms
9EE605A.7to81 Department of Technical Education Andhra Pradesh Name Designation Branch Institute Year/Semester Subject Subject Code Topic Duration Sub.
Department of Technical Education
9EE605A.11 Name Designation Branch Institute Year/Semester Subject Subject Code Topic Duration Sub Topic Teaching Aids : P. Balanarsimlu : Lecturer : Electrical.
Linear Data Structures
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
Give Eg:? Queues. Introduction DEFINITION: A Queue is an ordered collection of element in which insertions are made at one end and deletions are made.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
1 Midterm 1 on Friday February 12 Closed book, closed notes No computer can be used 50 minutes 4 questions Write a function Write program fragment Explain.
Queue ADT for lining up politely. COSC 2006 queue2 Queue – simple collection class  first-in first-out (FIFO) structure insert new elements at one end.
 In general, Queue is line of person waiting for their turn at some service counter like ticket window at cinema hall, at bus stand or at railway station.
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Circular Queues Maitrayee Mukerji. Queues First In – First Out (FIFO) The first element to be inserted is the first one to be retrieved Insertion at one.
STACKS & QUEUES for CLASS XII ( C++).
Review Array Array Elements Accessing array elements
Data Structures Using C, 2e
Queues.
CC 215 Data Structures Queue ADT
Chapter 15 Lists Objectives
Lectures Queues Chapter 8 of textbook 1. Concepts of queue
Queues Queues Queues.
Stack and Queue APURBO DATTA.
Introduction to Data Structure
Queues.
DATA STRUCTURE QUEUE.
Miscellaneous Drugs Tobacco PH
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
CE 221 Data Structures and Algorithms
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
Presentation transcript:

9CM Name :B Vijaya kumari Designation : Lecturer Branch :Computer Engineering Institute :Smt.B.Seetha. Polytechnic, Bhimavaram, Year/semester :III Sem Subject :Datastructrues Through C Sub code : 9CM-305 Topic :stacks& queues Duration :50 mins Subtopic :Data structure Sub topic :Circular queue using array implementation Teaching aids: :PPT, animations, Photographs Revised by : Bapuji naik Department Of Technical Education Andhra Pradesh

9CM Recap In the last class we have discussed about Queue using linked list.

9CM Objectives On completion of this topic, you would be able to know Circular queue Operation on circular queue

9CM Recap In the previous lesson we have learnt, implementation of circular queue using linked list

9CM Reading queues implementation with array has the drawback When an element is inserted, rear pointer is incremented Similarly when we delete element, front pointer is incremented Drawbacks of Queue

9CM Once we delete the element, there is no way to re use that location of the queue. In the above diagram, location with index 0 can not be re – used, as the operation manipulations any rear pointer not be front picture. Drawbacks of Queue Contd.,

9CM The problem can be overcome, if there is a facility to re – use the location indices. i.e., Once the maximum value of index in reached for either of front order, nest increment should point to the beginning of the queue. Drawbacks of Queue Contd.,

9CM For example, if the queue size in 5 the index value range from 0 to 4. Once the front of rear value reaches 4, nest of increment of either of them should problem 0. This is possible is the queue is arranged circularly Drawbacks of Queue Contd.,

9CM From the above discussion, it is clean that the location can be re used if we represent the queue circularly It make efficient uses if location of queue In a circular queue the last element and the first element of the queue are adjacent to each other Circular queue

9CM Representation of circular queue diagrammatically circular queue are representation as follows. The above queue has 6 location, index value range is 0 to 5 Once index value is 5, the next index is 0.

9CM Operations on circular queues The operations add the element at rear of the queue Delete operation deletes an element at front of the queue

9CM Initially front and rear have 0 value Diagrammatically, frontrear All elements are initially 0 Also, front = rear= 0 Operations on circular queues Contd., 5

9CM By adding an element ‘u‘ Front=0,rear=4 Operations on circular queues Contd., front rear u

9CM By adding some more elements the diagram look like, In the above diagram, A,E, S are added to the circular queue. front=0,rear=4 Operations on circular queues Contd., u a e s front0 rear

9CM Both the above scenario if we add two more elements the from are rear value are front=0, and rear=o front 5p q u a e s s rear Operations on circular queues Contd.,

9CM As, it can be draw, where the queue is empty the value of front are rear front=rear=0 Similarly, when the queue is full front=rear=0 on queue empty and queue full condition, front=rear=0 Contd., Operations on circular queues

9CM So for add a parathions were discussed On deleting element from the queue front is incremented front 0 0 e a u 5 rear front e a rear 5 u Contd., Operations on circular queues

9CM Before deletion front=0,rear=3 After deletion front=1,rear=3 The element value at front =1,u,is a no more usuful The location can be re- used later Continually with deletion, if the delete some more elements, the queue becomes empty. Again, the value of front and rear are front=0, rear=0 Contd., Operations on circular queues

9CM Summary In this lesson we have learnt The need for circular queue Representation of circular queue Operation of circular queue -add -delete Examples of operator

9CM Quiz 1.Regular queue are more efficient, compared to circular queue in array implementation a)True b)false

9CM The value of front are rear zero, in case of queue full as well as queue empty a) True b) false Quiz Contd.,

9CM In which situation head and tail pointers are points to same location a)Queue is full b)Queue is empty c)Both a&b d)None Quiz Contd.,

9CM In which end additions are made a)Head b)Tail c)Middle d)None Quiz Contd.,

9CM If queue is full then a)Head and tail pointers are points to same location b)Head and tail pointers are points to different locations c)a&b d)none Quiz Contd.,

9CM If queue is empty then a)Head and tail pointers are points to different locations b)Head and tail pointers are points to same location c)Both head and tail pointers are points to middle point d)a&c Quiz Contd.,

9CM In dequeue operation the tail pointer is a) incremented b) Decremented c) a&b d) None Quiz Contd.,

9CM In enqueue operation the head pointer is a) Incremented a)Decremented b)Same point c)b&c Quiz Contd.,

9CM Frequently asked questions 1.What is a circular queue? 2.Explain the operations of circular queue? 3.Explain full and empty conditions of a circular queue?

9CM