Www.btechsmartclass.com. Introduction Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle.

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

© 2004 Goodrich, Tamassia Queues1. © 2004 Goodrich, Tamassia Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions.
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
Ceng-112 Data Structures I Chapter 5 Queues.
Data Structures Lecture 13: QUEUES Azhar Maqsood NUST Institute of Information Technology (NIIT)
Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
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.
Array based Queues A circular implementation. Implementation Option 1 As with a array based stack, there are multiple ways that a queue can be implemented.
Data Structures Queue Namiq Sultan 1. Queue A queue is an ordered collection of items into which items may be added at one end (rear) and from which items.
1 Stack and Queue. 2 Stack In Out ABCCB Data structure with Last-In First-Out (LIFO) behavior.
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.
1 Queues – Chapter 3 A queue is a data structure in which all additions are made at one end called the rear of the queue and all deletions are made from.
A queue is an ADT which allows data values to be accessed only one at a time and only the first inserted. The rule imposed on a queue is: First In First.
What is a Queue? n Logical (or ADT) level: A queue is an ordered group of homogeneous items (elements), in which new elements are added at one end (the.
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.
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
1 Queues and Lists. QUEUES Very similar to stacks The only difference between them is in the order in which elements are processed. A stack uses a last-in/first-out.
STACKS AND QUEUES. A LINKED LIST IMPLEMENTATION OF A QUEUE data next data next NULL data next cnt front rear queue node Queue: First-In-First-Out (FIFO)
CSE 12 – Basic Data Structures Cynthia Bailey Lee Some slides and figures adapted from Paul Kube’s CSE 12 CS2 in Java Peer Instruction Materials by Cynthia.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
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.
© 2004 Goodrich, Tamassia Queues1. © 2004 Goodrich, Tamassia Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions.
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.
Lab 7 Queue ADT. OVERVIEW The queue is one example of a constrained linear data structure. The elements in a queue are ordered from least recently added.
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.
Computer Science Department Data Structures and Algorithms Queues Lecture 5.
CE 221 Data Structures and Algorithms
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
1 Queues and Lists. QUEUES Very similar to stacks The only difference between them is in the order in which elements are processed. A stack uses a last-in/first-out.
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.
Computer Engineering Rabie A. Ramadan Lecture 6.
STACK Data Structure
Queues 1. Queue  a queue represents a sequence of elements where elements can be added at the back of the sequence and removed from the front of the.
1 Data Structures CSCI 132, Spring 2014 Lecture 7 Queues.
 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.
1 Data Structures and Algorithms Queue. 2 The Queue ADT Introduction to the Queue data structure Designing a Queue class using dynamic arrays Linked Queues.
Queues By Jimmy M. Lu. Overview Definition Standard Java Queue Operations Implementation Queue at Work References.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Abstract Data Types Queues Dale Roberts, Lecturer
STACKS & QUEUES for CLASS XII ( C++).
What is a Queue? Queue is a linear data structure in which the insertion and deletion operations are performed at two different ends. In a queue data structure,
Lecture No.09 Data Structures Dr. Sohail Aslam
CS505 Data Structures and Algorithms
Chapter 15 Lists Objectives
Queue data structure.
Stacks and Queues.
Stack and Queue APURBO DATTA.
Queues Chapter 4.
CSCE 3110 Data Structures & Algorithm Analysis
Stack and Queue.
Data Structures and Database Applications Queues in C#
CMSC 341 Lecture 5 Stacks, Queues
Principles of Computing – UFCFA3-30-1
Queues 11/9/2018 6:28 PM Queues 11/9/2018 6:28 PM Queues.
Queues 11/16/2018 4:18 AM Queues 11/16/2018 4:18 AM Queues.
Queues 11/16/2018 4:19 AM Queues 11/16/2018 4:19 AM Queues.
Queues.
DATA STRUCTURE QUEUE.
Queues 11/22/2018 6:47 AM 5.2 Queues Queues Dr Zeinab Eid.
Memory Organization Process 1 (browser) Code Process 3 (word)
Queues 3/9/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Queues 12/30/2018 9:24 PM Queues 12/30/2018 9:24 PM Queues.
Queues FIFO Enqueue Dequeue Peek.
Abstract Data Type Abstract Data Type as a design tool
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Queues Jyh-Shing Roger Jang (張智星)
Stacks and Queues.
CSCS-200 Data Structure and Algorithms
Presentation transcript:

Introduction Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle. Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle. In a Queue always the Insertion operation is done at “rear” and Deletion operation is done at “front”. In a Queue always the Insertion operation is done at “rear” and Deletion operation is done at “front”. In a Queue sequence of elements entered into the queue is same as the sequence of elements leave the queue. In a Queue sequence of elements entered into the queue is same as the sequence of elements leave the queue.

Queue Definition Queue is a linear Data Structure in which the operations are performed based on FIFO (First In First Out) principle. Fields rear – used to store the position of insertion front – used to store the position of deletion size – used to store the size of the queue element – used to store the value to be inserted Functions enQueue(element) – to insert into queue deQueue( ) – to delete from queue display( ) – to display all elements in queue Condition Rear >= size – Queue is full Front == rear – Queue is empty

#define size 10 void main() { int Q[size], front = -1, rear = -1,op,element; void enQueue(int); void deQueue(); void display(); printf(“Select your option: ”); printf(“1: Insert\n2: Delete\n3: Display\n”); scanf(“%d”,&op); switch(op) { case 1: printf(“Enter element to be insert: ”); scanf(“%d”,&element); enQueue(element); break; case 2: deQueue(); break; case 3: display(); break; } }

f = front r = rear f = r = -1 Q Queue is EMPTY Queue is EMPTY SIZE-1 When the compiler executes above code it allocates memory as follows….

Insertion Q enQueue( int element ) { if( rear != size-1) { rear ++; Q[rear] = element; } } else printf(“Queue is full !!!”); enQueue(10) enQueue(20) 20 enQueue(30) 30 enQueue(40) 40

Deletion Q deQueue( ) { if( front != rear ) { front ++; printf(“\nElement removed : %d”,Q[front]); } } else printf(“Queue is empty !!!)”; deQueue( ) deQueue( )

Display Q if( front != rear ) { for(int i=front+1; i<=rear, i++) printf(“%d\t”,Q[i]); } } else printf(“Queue is empty !!!”); display( ) display( ) {