Jeff West - Quiz Section 15

Slides:



Advertisements
Similar presentations
Queues. Queue Definition Ordered list with property: All insertions take place at one end (tail) All insertions take place at one end (tail) All deletions.
Advertisements

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.
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
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 a waiting line…….  It’s in daily life:-  A line of persons waiting to check out at a supermarket.  A line of persons waiting.
Chapter 7 Queues. Data Structure 2 Chapter Outline  Objectives  Follow and explain queue-based algorithms using the front, rear, entering the queue,
ADT Queue 1. What is a Queue? 2. STL Queue 3. Array Implementation of Queue 4. Linked List Implementation of Queue 5. Priority Queue.
LINKED QUEUES P LINKED QUEUE OBJECT Introduction Introduction again, the problem with the previous example of queues is that we are working.
Jerry Lebowitz.  Stacks  Queues 3 C++ Programming: From Problem Analysis to Program Design, Sixth Edition.
Chapter 13 Pointers and Linked Lists. Nodes and Linked Lists Linked list: A sequence of nodes in which each node is linked or connected to the node preceding.
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.
Linked Lists1 Part-B3 Linked Lists. Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data structure consisting of a sequence.
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.
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.
CSC 212 Stacks & Queues. Announcement Daily quizzes accepted electronically only  Submit via one or other Dropbox  Cannot force you to compile & test.
Reference: Vinu V Das, Principles of Data Structures using C and C++
DATA STRUCTURES AND ALGORITHMS Lecture Notes 4 Prepared by İnanç TAHRALI.
1 Chapter 7 Stacks and Queues. 2 Stack ADT Recall that ADT is abstract data type, a set of data and a set of operations that act upon the data. In a stack,
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.
Data Structures: Advanced Damian Gordon. Advanced Data Structure We’ll look at: – Linked Lists – Trees – Stacks – Queues.
UNIT II Queue. Syllabus Contents Concept of queue as ADT Implementation using linked and sequential organization. – linear – circular queue Concept –
Lecture 20 Stacks and Queues. Stacks, Queues and Priority Queues Stacks – first-in-last-out structure – used for function evaluation (run-time stack)
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
الطابور QUEUE (abstract data type) واحد من هياكل البيانات الخطية الشائعة الاستخدام داخل البرامج. يحتوي علي عناصر من نفس النوع. من أنواع البيانات الخطية.
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.
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.
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++).
Programming Circular Linked List.
Unit-3 Queues-operations, array and linked representations. Circular Queue operations, Dequeues, applications of queue.
CS505 Data Structures and Algorithms
Chapter 15 Lists Objectives
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Queue data structure.
Week 15 – Monday CS221.
Programming Abstractions
Stack and Queue APURBO DATTA.
LinkedList Class.
8-1.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Pointers and Linked Lists
CSC215 Homework Homework 11 Due date: Dec 19, 2016.
8-1.
Queue, Deque, and Priority Queue Implementations
Queue, Deque, and Priority Queue Implementations
DATA STRUCTURE QUEUE.
ليست هاي پيوندي.
Linked List (Part I) Data structure.
Stack and Queues Stack implementation using Array
COMPUTER 2430 Object Oriented Programming and Data Structures I
CSC 143 Queues [Chapter 7].
18.5 Linked Queues Like a stack, a queue can be implemented using pointers and nodes Allows dynamic sizing, avoids issue of wrapping indices NULL front.
Sequences 12/8/2018 3:02 AM Linked Lists Linked Lists.
ADT list.
Implementing Hash and AVL
Queues FIFO Enqueue Dequeue Peek.
Data structures.
Stacks and Queues 1.
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
Jeff West - Quiz Section 9
Stacks and Queues.
Lecture 16 Stacks and Queues CSE /26/2018.
Stacks LIFO C C B B B B A A A A A Push (A) Push (B) Push (C) Pop Pop.
Jeff West - Quiz Section 16
CS210- Lecture 6 Jun 13, 2005 Announcements
CSC 248 – fundamentals of Data structure
Lecture 16 Stacks and Queues CSE /26/2018.
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Getting queues right … finally (?)
Linked Lists.
Presentation transcript:

Jeff West - Quiz Section 15 CSE 143 Section AD Quiz Section 15 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 Announcements First part of HW 5 due today, you’ll get it back Thursday… Quiz Thursday – Stacks & Queues Homework 5 Demo sign-up sheet going around… Final Review Sessions next Wednesday and Thursday nights – time & location TBA 10 more days until our summer vacation… Tha Usual… 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 Agenda Linked List Examples from Last Time Stacks Queues Event Handling 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 Stacks Stacks follow a FILO (First-In-Last-Out) pattern… Their behind-the-scenes implementation can be handled using arrays, linked lists, vectors, etc. 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 Queues Queues follow a FIFO (First-In-First-Out) pattern… 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 Queue.h (Linked List) struct Node { Flight myFlight; Node* next; } Class FlightQueue { public: FlightQueue(); ~FlightQueue(); FlightQueue(FlightQueue&); void insert(const Flight&); // add element to rear of queue Flight remove(); // remove element from front of queue Flight getFront(); // return a copy of element at the front of queue private: Node* front; Node* back; 8/7/2001 Jeff West - Quiz Section 15

FlightQueue::FlightQueue(); front = NULL; back = NULL; } 8/7/2001 Jeff West - Quiz Section 15

FlightQueue::~FlightQueue() Node* cur = front, *temp; while(cur != NULL) { temp = cur; cur = cur->next; delete temp; } 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 Copy Constructor FlightQueue::FlightQueue(FlightQueue& other) { front = back = NULL; Node* curOfOther = other.front; while(curOfOther != NULL) { insert(curOfOther); curOfOther = curOfOther -> next; } 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 insert void FlightQueue::insert(const Flight& newFlight) { Node* addMe = new Node; addMe -> myFlight = newFlight; addMe -> next = NULL; if(front == NULL) front = back = addMe; else { back -> next = addMe; back = addMe; } 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 remove Flight FlightQueue::remove() { if(back == front) back = NULL; Flight returnMe = front -> myFlight; Node* newFront = front -> next; delete front; front = newFront; return returnMe; } 8/7/2001 Jeff West - Quiz Section 15

Jeff West - Quiz Section 15 getFront Flight FlightQueue::getFront() { return front -> myFlight; } 8/7/2001 Jeff West - Quiz Section 15