CS2852Week 5, Class 2 Today
Queue Applications Circular Queue Implementation Testing
SE-2811Slide design: Dr. Mark L. Hornick
Content: Dr. HornickErrors: Dr. Yoder
1
Printer queue Customer queue This week’s lab (resonance simulation)
Parsing Matching parenthesis Compiling expressions
Function call stack
Queue Applications
SE-2811Dr.Yoder 2
Stack Applications
A queue interface (Review)
public interface Queue<E> { E poll(); void offer(E element); E peek(); boolean isEmpty();}
(Not in Java API – see code examples)SE-2811Dr.Yoder 3
Implementing a Queue (Review) With Java’s ArrayList:
push: add(0,E) – EXERCISE: What is the Big-O? pop: remove(n-1) – EXERCISE: Big-O? peek: [EXERCISE!] – EXERCISE: Big-O? isEmpty: isEmpty()
With Java’s LinkedList: push: add(0,E) – EXERCISE: What is the Big-O? pop: remove(n-1) – EXERCISE: Big-O? peek: [EXERCISE!] – EXERCISE: Big-O? isEmpty: isEmpty() SE-2811
Dr.Yoder 4
Two methods for each operation: One throws exceptions if nothing there The other returns null
Java’s Queue Interface (Review)
SE-2811Dr.Yoder 5
Throws exception
Returns special value
Insert add(e) offer(e)Remove remove() poll()Examine element() peek()
Implementing a Circular Queue [See code]
SE-2811Dr.Yoder 6
Levels of Testing Unit – e.g. Single method or class Integration – e.g. Multiple classes System – Whole program in context used Acceptance – Confirming requirements met
SE-2811Dr.Yoder 7
Types of Testing Black-box testing – What we have done so
far White-box testing – Code coverage, etc. Broken-box testing
SE-2811Dr.Yoder 8
Muddiest Point
Wait for the slides, or follow this link to answer both questions at once: http://bit.ly/1Mow5a3
SE-2811Dr.Yoder 9
SE-2811Dr. Josiah Yoder 10http://bit.ly/1Mow5a3
SE-2811Dr. Josiah Yoder 11http://bit.ly/1Mow5a3