March 29 – Testing and Priority QUeues

Slides:



Advertisements
Similar presentations
 Abstract Data Type Abstract Data Type  What is the difference? What is the difference?  Stacks Stacks  Stack operations Stack operations  Parsing.
Advertisements

Queues and Priority Queues
Queues and Priority Queues
CSCA48 Course Summary.
1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.
April 27, 2017 COSC Data Structures I Review & Final Exam
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.
Week 15 – Monday.  What did we talk about last time?  Tries.
Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Final Exam Review CS 3358.
CSE373: Data Structures & Algorithms Priority Queues
CSE 1342 Programming Concepts
Queues Chapter 8 (continued)
Review Array Array Elements Accessing array elements
Elementary data structures
Queues.
Week 4 - Monday CS221.
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
Understanding Algorithms and Data Structures
COSC160: Data Structures: Lists and Queues
Week 4 - Friday CS221.
September 29 – Stacks and queues
May 17th – Comparison Sorts
Program based on queue & their operations for an application
March 27 – Course introductions; Adts; Stacks and Queues
Chapter 15 Lists Objectives
CS 1114: Implementing Search
Stacks and Queues.
Queues Queues Queues.
Data Structures Interview / VIVA Questions and Answers
Cse 373 May 15th – Iterators.
Week 15 – Monday CS221.
October 30th – Priority QUeues
Cse 373 April 14th – TreEs pt 2.
March 31 – Priority Queues and the heap
September 27 – Course introductions; Adts; Stacks and Queues
Cse 373 April 26th – Exam Review.
i206: Lecture 11: Stacks, Queues
Lecture 1: Welcome to CSE 373
CMSC 341 Lecture 5 Stacks, Queues
structures and their relationships." - Linus Torvalds
Principles of Computing – UFCFA3-30-1
Exam 2 Review CS 3358 Data Structures.
Stacks, Queues, and Deques
structures and their relationships." - Linus Torvalds
Exam 2 Review CS 3358 Data Structures.
Lecture 3: Queues, Testing, and Working with Code
Queues 11/22/2018 6:47 AM 5.2 Queues Queues Dr Zeinab Eid.
Stacks, Queues, and Deques
CSE332: Data Abstractions Lecture 4: Priority Queues
Exam 2 Review CS 3358 Data Structures.
Stacks and Queues CSE 373 Data Structures.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Figure 7.1 Some queue operations. Figure 7.1 Some queue operations.
Stacks and Queues CSE 373 Data Structures.
CSE 373 Data Structures Lecture 6
Priority Queues & Heaps
Introduction to Data Structure
QUEUE Visit for more Learning Resources Free Powerpoint Templates.
CE 221 Data Structures and Algorithms
Stacks and Queues CSE 373 Data Structures.
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
CSE 373 Data Structures Lecture 6
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
Stacks, Queues, and Deques
CSCS-200 Data Structure and Algorithms
Queues and Priority Queue Implementations
structures and their relationships." - Linus Torvalds
Queues.
CMPT 225 Lecture 8 – Queue.
Presentation transcript:

March 29 – Testing and Priority QUeues Cse 373 March 29 – Testing and Priority QUeues

Assorted minutiae Midterm exam: April 28th; 2:30 – 3:20 Canvas Site is up – HW1 out after class 143 Workshop Late this week or early next

Assorted minutiae HW 1 Two parts Implementation and Testing Part 1 (143 review) Part 2 (Testing)

Today’s Schedule Circular Queues Software Testing New ADT: Priority Queue

Continuing from last week Stacks and Queues Linked List v. Array Implementation Design decisions and “resizing” Alternating push and pop situation

Circular Queues

Circular Queues Front Back

Circular Queues Front Back

Circular Queues Why this way? What function to front and back serve?

Circular Queues Front Back enqueue(4)

Circular Queues Front Back 4 Which operations will move what pointers?

Circular Queues Front Back 4 Let’s do several enqueues

Circular Queues What happens now, on enqueue(7)? Front Back 4 5 9 2 3 1 6 What happens now, on enqueue(7)?

Circular Queues Problems here? How to implement? Front Back 4 5 9 2 3 1 6 7 Problems here? How to implement?

Circular Queues Front Back 4 5 9 2 3 1 6 7 The queue is full, but it is the same situation (front == back) as when the queue is empty. This is a boundary condition.

Circular Queues Front Back 4 5 9 2 3 1 6 7 We have to resize the list (or deny the add) if we get another enqueue.

Circular Queues What if we dequeue some items? Front Back 4 5 9 2 3 1 6 7 What if we dequeue some items?

Circular Queues Dequeue() outputs 4 Is the 4 really “deleted”? Front Back 5 9 2 3 1 6 7 Dequeue() outputs 4 Is the 4 really “deleted”?

Circular Queues Front Back 9 2 3 1 6 7 Dequeue outputs 5

Circular Queues Now we’ve freed up some space and can enqueue more Front Back 9 2 3 1 6 7 Now we’ve freed up some space and can enqueue more

Circular Queues By moving the front and back pointers, we can utilize all of the space in the array Advantages over a linked list? Fixed number of items Small data (Memory efficiency) BONUS: What is the memory overhead of the linked list?

Testing Implementation is great if it works on the first try In a large implementation, what is causing the problem? Object oriented programming allows modularity – good testing can pinpoint bugs to particular modules

Testing Two primary types of testing Black box Behavior only, no peeking into the code White box (or clear box) Where there is an understanding of the implementation that can be leveraged for testing

Testing Part 1 on the homework will involve writing tests for your own implementation. (White box) Part 2 will involve testing java .class files. Only the interface (TestQueue) and expected behavior are known

Testing Isolate the problem Write specific tests Running the whole program doesn’t help narrow down problems What are expected test cases? In general: [0,1,n] are good starting points White box testing can take advantage of boundary cases (e.g. the resize of an array)

Testing Many test cases (and large ones) You can prove that an algorithm is correct, but you cannot necessarily prove an arbitrary implementation is correct More inputs can increase certainty Adversarial testing The client is not your friend

Priority Queue New ADT Objects in the priority queue have: Data Conditions Lower priority items should dequeue first Change priority?

Priority Queue Applications? Hospitals CSE course overloads Etc…

Priority Queue How to implement? Keep data sorted (somehow) Array? Inserting into the middle is costly (must move other items) Linked list? Must iterate through entire list to find place Cannot move backward if priority changes

Priority Queue These implementations will all give us the behavior we want as far as the ADT, but they may be poor design decisions Any other data structures to try?

Next Class Improve upon LL v. Array ADTs v. Data Structures DS properties and their importance Implementation impacts