# Lectures

Here we have space to list detailed reading expectations for each lecture, along with instructor commentary that may be a little tangential.

## Lecture 25: Priority queues and heaps

• Chapter 7: 7.19–7.21
• Chapter 8: 8.34
• Chapter 24: 24.32–24.34
• Chapter 27

#### Instructor’s notes

The textbook places the root of the tree at array index 1 instead of 0, which simplifies the parent/children formulas a bit. But it later reimplements reheap() (analogous to our bubbleDown()) using a 0-based convention for use in heapsort. We’ll stick to the 0-based convention.

The textbook makes a point of avoiding swaps when bubbling up and down by only moving existing values and not writing the new value until its final location is known. This is a legitimate optimization, but we’ll stick with swaps because they make it easier to visualize the comparisons that are taking place.

At this point in the textbook, its method specifications range from poor to missing altogether. We’ll try to do better in our demo code.

## Lecture 24: Shortest paths

#### Instructor’s notes

The online reading (including videos) from JavaHyperText is much more thorough than the textbook on this topic, highlighting the loop invariant and proof of correctness.

## Lecture 23: Graph traversals

• Chapter 29: 29.11–29.15
• Chapter 30: 30.23

#### Instructor’s notes

DFS is most cleanly implemented recursively (as in lecture), which is not shown in the textbook. The textbook’s iterative implementation does a better job of matching a recursive version than others I’ve seen (e.g. JavaHyperText), but the pseudocode leaves out some details, and there is no concrete implementation in chapter 30.

The textbook’s treatment of topological sorting describes Kahn’s algorithm, but in reverse, starting with the last vertex in the order and accumulating vertices in a Stack to effectively reverse the order that they were added in. It also only provides pseudocode, leaving out details for how to efficiently find nodes with no successors after vertices have been removed. The lecture slides and demo code show the “forward” Kahn’s algorithm, including an efficient way of identifying nodes with no predecessors. Discussion activity 12 will introduce an alternative algorithm that uses depth-first search instead (which I find more elegant). It turns out that reversing the DFS “settled” order gives a topological order.

• Take Quiz 12 on Canvas

## Lecture 22: Graphs

• Chapter 29: 29.1–29.10, 29.25–29.26
• Chapter 30: 30.1–30.22

#### Instructor’s notes

We will cover chapters 29 and 30 over the course of two or three lectures. The graph algorithms parts of the chapters are the main sections we skip in this introductory lecture. So for today’s reading you can skip over anything about traversals or shortest paths; we’ll come back to those later. Do concentrate on terminology and on representations.

## Lecture 21: Synchronization

#### Instructor’s notes

The textbook does not cover concurrency. The Java Tutorial lesson Concurrency is a good reference for this lecture and the previous. For more detail, including lots of examples, read Java Concurrency in Practice. You should be familiar with the following general concepts:

• Producer–consumer problems
• Ring buffers
• Locks (mutexes) and the synchronized keyword
• Condition variables: wait() and notifyAll()

• Take Quiz 11 on Canvas

## Lecture 20: Concurrency

#### Instructor’s notes

The textbook does not cover concurrency. The Java Tutorial lesson Concurrency is a good reference for this lecture and the next. You should be familiar with the following general concepts:

• Java’s Thread class
• Runnable
• Concurrent execution via time slicing or parallelism
• Race conditions

## Lecture 19: Event-driven programming

#### Instructor’s notes

• Take Quiz 10 on Canvas
• Start working on Assignment 5

## Lecture 17: Dictionaries and hashing

• Chapter 20—Dictionaries
• Chapter 22—Introducing Hashing: 22.1–22.8, 22.10–22.15, 22.24–22.26
• Chapter 23—Hashing as a Dictionary Implementation: 23.1–23.2, 23.6–23.8, 23.16–23.17

#### Instructor’s notes

• Take Quiz 9 on Canvas

## Lecture 16: Sorting

• Chapter 15—An Introduction to Sorting: 15.1–15.14
• Chapter 16—Faster Sorting Methods: 16.1–16.7, 16.9–16.19, 16.23

## Lecture 15: Loop invariants

• Take Quiz 8 on Canvas

## Lecture 14: Trees II

• Optionally take Quiz 7 on Canvas
• Start working on Assignment 4

## Lecture 13: Trees I

• Chapter 24: 24.1–24.17, 24.22–22.24, 24.28–24.31
• Chapter 25: 25.1–25.2, 25.9–25.11, 25.18
• Chapter 26: 26.1–26.18, 26.40–26.43

## Lecture 12: Recursion

• Chapter 5—Stacks: 5.22
• Chapter 9—Recursion

• Take Quiz 6 on Canvas

• JavaHyperText: recursion (do you get the joke?)
• Myers: Recursion
• Chapter 14—Problem Solving with Recursion

## Lecture 11: Efficiency

• Chapter 4—The Efficiency of Algorithms
• Chapter 19—Searching: 19.1–19.18, 19.21–19.24 (skips recursive searches, for now; will revisit in Lecture 15)

## Lecture 10: Ordered collections

• Chapter 5—Stacks: 5.1–5.4
• Chapter 6—Stack Implementations: 6.1–6.12
• Chapter 7: 7.1–7.13 (Queue ADT)
• Chapter 8: 8.1–8.16 (Queue implementations: linked and array-based)
• Chapter 10—Lists
• Chapter 11—A List Implementation That Uses an Array: 11.1–11.13
• Chapter 12—A List Implementation That Links Data: 12.1–12.24

• Take Quiz 5 on Canvas

• Chapter 3—A Bag Implementation That Links Data

• Start working on Assignment 3

## Lecture 8: Generics

• Introduction—Organizing Data
• Chapter 1—Bags
• Java Interlude 1—Generics
• Chapter 2—Bag Implementations That Use Arrays

• Take Quiz 4 on Canvas

## Lecture 7: Exceptions, I/O

• Java Interlude 2—Exceptions
• Java Interlude 3—More About Exceptions: J3.1–J3.8
• Supplement 1—Java Basics: S1.32–S1.37, S1.81–S1.85
• Supplement 2—File Input and Output: S2.1–S2.19
• Input/output in Java

## Lecture 6: Inheritance

• Appendix C—Creating Classes from Other Classes: C.1–C.24
• Prelude—Designing Classes: P.21–P.22, P.28–P.31

• Take Quiz 3 on Canvas
• Review Assignment 1 feedback
• Look up your prelim 1 exam time and mark it in your planner. If you have a conflict, fill out the prelim 1 conflict survey on Canvas

## Lecture 5: Interfaces, subtyping

• Prelude—Designing Classes: P.12–P.20

• Start working on Assignment 2

## Lecture 4: Specifications, testing

• Appendix A—Documentation and Programming Style: A.1–A.12
• Code style

• Take Quiz 2 on Canvas

## Lecture 3: Abstraction, encapsulation

• Prelude—Designing Classes: P.1–P.11
• Appendix B—Java Classes: B.17–B.26

• Look up your prelim 1 exam time and mark it in your planner. If you have a conflict, fill out the prelim 1 conflict survey on Canvas (postponed due to registrar glitch)

## Lecture 2: Objects

Unless linked or otherwise specified, readings refer to chapters and sections from our textbook, Data Structures and Abstractions with Java, Fifth Edition. If you do not have a paper copy, you should be able to access an electronic version via the “Course Materials” link on Canvas.

• Appendix B—Java Classes: B.1–B.16, B.22–B.28, B.34–B.35
• Java Interlude 6—Mutable and Immutable Objects
• Object Diagram Rules

• Take Quiz 1 on Canvas

## Lecture 1: Course overview

There are a lot of these after the first lecture, but don’t worry—the pace will even out quickly.

• Follow the setup guide to install and configure IntelliJ on your computer
• Read the syllabus (yes, all of it) and take the syllabus quiz on Canvas
• If you are new to Java, read the transition to Java guide
• Access the textbook’s online supplement 1: Java Basics (this will be assigned reading for the next few lectures, but it is only available online)
• Start working on Assignment 1