CS2852 Week 5, Class 2 Today Queue Applications Circular Queue Implementation Testing SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1
Printer queue Customer queue This week’s lab (resonance simulation) Parsing Matching parenthesis Compiling expressions Function call stack Queue Applications SE-2811 Dr.Yoder 2 Stack Applications
A queue interface (Review) public interface Queue { E poll(); void offer(E element); E peek(); boolean isEmpty(); } (Not in Java API – see code examples) SE-2811 Dr.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-2811 Dr.Yoder 5 Throws exception Returns special value Insertadd(e)offer(e) Removeremove()poll() Examineelement()peek()
Implementing a Circular Queue [See code] SE-2811 Dr.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-2811 Dr.Yoder 7
Types of Testing Black-box testing – What we have done so far White-box testing – Code coverage, etc. Broken-box testing SE-2811 Dr.Yoder 8
Muddiest Point Wait for the slides, or follow this link to answer both questions at once: SE-2811 Dr.Yoder 9
SE-2811 Dr. Josiah Yoder 10
SE-2811 Dr. Josiah Yoder 11