CS361, Summer 2024

CS361 Outline

Summer 2024, Steven Zeil

Upcoming Events
1 Overview and ADTs Review: 05/13/2024 - 05/19/2024

Overview

Coming into this course, you should already be familiar with Abstract Data Types and with the way that Java classes are used to implement them.

To be certain that everyone is on the same page, however, this module examines some critical information about ADTs & classes in Java.

Some of this material should be review for you. If not, you can find more detailed treatments in the pre-requisite course CS251. Some optional review readings have been suggested as well.

We will also take the time to focus on some fine points of class implementation that you may not have seen much prior emphasis on, particularly copying and comparing objects.

This opening week of the course is also an opportunity to select your personal programming environment for use in this course. We will look briefly back at the options that you practiced in CS252 and will offer some additional possibilities.

Activities
  1. event Attend: Orientation 05/13/2024, 7:30PM EDT
  2. reading Review as necessary: Java Classes and Objects
  3. reading Read Abstract Data Types, 4.1 … 4.2
  4. lecture Read: Abstraction and Abstract Data Types
  5. reading Review as necessary: Java Interfaces and Inheritance
  6. lecture Read: Copying Data

  7. lecture Read: Comparing Data
  8. lecture Read: A Class Designer's Checklist for Java
  9. lab Do: Setting Up Your Personal Development Environment
  10. video Watch Getting Assignment Code from GitHub Classroom

  11. video Watch Working with Assignment Code (Eclipse) or Working with Assignment Code (VSCode)
  12. lab Do: Lab 1: Setting Up Your Programming Environment 05/19/2024

  13. lab Do: Survey: When is a good time for weekly Q&A meetings? Take this survey in Canvas.
  14. asst Do the assignment: Assignment 1. Working with classes Due: 05/21/2024

2 Polymorphism & Iterators: 05/20/2024 - 05/25/2024

Overview

  • Polymorphism is the ability of a programming language to apply the same code to values of different data types.

    Java supports polymorphism in three ways:

    • Overloading: providing different functions with the same name, selecting the desired function body based upon the data types of the parameters,
    • Overriding: providing different functions with the same name and parameters within different classes of na inheritance hierarchy, selecting the desired function body based upon the data type of the object to which it was applied.
    • Generics: a mechanism for writing a single function or class as an algorithmic pattern that can be applied to a wide variety of different data types.
  • Iterators are a data abstraction for the notion of a position within a container of data. Iterators allow us to express many simple algorithms in a simple form, regardless of whether the underlying container is an array, a linked list, a tree, or some other data structure.

Generics and iterators are often used together to provide patterns for code that can be applied to a wide range of underlying data structures.

3 Algorithm Analysis: 05/26/2024 - 05/31/2024

Overview

An important theme throughout this semester will be viewing the process of developing software as an engineering process. Now, engineers in traditional engineering disciplines, civil engineers, electrical engineers, and the like, face trade offs in developing a new product, trade offs in cost, performance, and quality.

Software developers face the same kinds of choices. Early on, you may have several alternative designs and need to make a decision about which of those designs to actually pursue. It’s no good waiting until the program has already been implemented, written down in code. By then you’ve already committed to one design and invested significant resources into it.

In this module, we’ll look at mathematical techniques for analyzing algorithms to determine what their speed will be, or, more precisely, how badly their speed will degrade as we apply them to larger and larger amounts of data. The key to doing this will be to analyze the code for its worst case complexity.

Activities
  1. lecture Read: Analysis of Algorithms: Motivation
  2. reading Read Algorithm Analysis Ch 8
  3. selfassess Take the self-assessment: Big-O Algebra

  4. lecture Read: Analyzing the Worst-Case Complexity

  5. selfassess Take the self-assessment: Complexity: step-by-step, short program fragments (in Canvas)
  6. lecture Read: Case Studies: Analyzing Standalone Functions

  7. selfassess Take the self-assessment: Complexity: functions (in Canvas)
  8. quiz Take the quiz: Quiz: Worst Case Complexity (in Canvas) Due: 05/31/2024

4 Arrays and Lists: 06/01/2024 - 06/06/2024

Overview

A substantial amount of the data that we work with is arranged into a simple linear ordering, one thing after another. Of course, you are already quite familiar with one way of doing this, by putting the data into arrays.

In this module we explore one of the two most common variations on ADTs for maintaining data in a sequence: array-style storage and linked-lists.

Array-style storage provides $O(1)$ access to any element in the sequence, but can require lengthy ($O(n)$) operations to add or remove elements.

Linked lists allow for efficient ($O(1)$) insertion and removal of data from any location in the sequence, at the cost of limiting access to moving sequentially from one end of the list to the other.

Activities
  1. reading Read Arrays 9.1 … 9.3
  2. lecture Read: Introduction to the Java API
  3. lecture Read: Collection and List
  4. lecture Read: ArrayList
  5. lab Do: Under Construction
  6. reading Read Lists 9.4 … 9.7

  7. lecture Read: Linked Lists
  8. lecture Read: Linked List Applications in Operating Systems
  9. lecture Read: java.util.LinkedList
  10. asst Do the assignment: Lists & Iterators Due: 06/06/2024

5 Functional Programming: 06/07/2024 - 06/10/2024

Overview

Functional programming is a style of coding that treats functions as data, allowing them to be passed to and returned from other functions, stored in data structures, and, of course, still be called/executed like a function.

Java has a number of places where it supports the functional style. In some cases this is optional. In others this is simply a means to writing cleaner, more readable code.

Activities
  1. lab Do: Review the exam procedures and set up your proctoring for the Midterm exam. 06/06/2024
  2. lecture Read: Functors & Functional Programming
  3. reading Read Anonymous Classes
  4. reading Read Lambda Expressions
  5. lecture Read: Immediate Classes and Lambda Expressions
  6. lab Do: TBD Due: 06/10/2024
6 Recursion, Stacks and Queues: 06/11/2024 - 06/14/2024

Overview

Recursion is a style of programming in which a function solves a problem by calling itself on “smaller” subproblems, then combines the subproblem solutions into a solution of the overall problem. Recursion is an alterative to iteration (looping) that can sometimes lead to cleaner code.

Sometimes one can achieve more readable, expressive algorithms by using ADTS that limit one’s choices. Stacks and queues do not do anything that an ArrayList or LinkedList cannot, but they limit us to access and modify their contents only at the ends of the sequence, never in the interior. There are a number of useful algorithms that work perfectly within these limitations.

  • Stacks are very useful for algorithms that match pairs of items in a “nested” structure.
  • Queues are a key element in algorithms that need to “schedule” work to be done in future iterations.

Stacks can also be used to rewrite a recursive algorithm into an iterative form.

Activities
  1. lecture Read: Recursion
  2. lab Do: TBD
  3. reading Read Lists 9.8 … 9.14.
  4. lecture Read: Stacks
  5. lecture Read: Converting Recursion to Iteration
  6. lecture Read: Queues
  7. video Watch Working with Queues

  8. asst Do the assignment: Stacks/Queues Due: 06/14/2024

7 Sorting and Average Case Complexity : 06/15/2024 - 06/20/2024

Overview

In Part I, we analyzed the speed of algorithms exclusively from the point of view of the worst case. One might argue that this is unnecessarily pessimistic on our part. There are some algorithms for the worst case input is rare enough that we might not be worried about it, particularly if we believe that typical inputs can be handled much more quickly.

We therefore next turn to the idea of average case complexity a measure of how the average behavior of a program degrades as the input sets get larger and larger.

A common class of algorithms for which average case analysis is particularly important are sorting algorithms: arranging a sequence of items into a desired order.

Activities

Average Case

  1. reading Read Best, Worst, & Average Cases 8.4

  2. lecture Read: Average Case Analysis

  3. video Watch Analysis example: loading and searching sequences

  4. video Watch Analysis example: loading and searching sequences (part 2)

Sorting

  1. reading Read Sorting, 13.1 – 13.3, 13.5 – 13.7, 13.9 – 13.11, 13.16

  2. lecture Read: Sorting Speed Limits

  3. lecture Read: Sorting --- Merge Sort

  4. lecture Read: Sorting --- Quick Sort

  5. selfassess Take the self-assessment: Self-Assessment: Sorting

  6. asst Do the assignment: Timing Due: 06/23/2024

Midterm Exam

  1. exam Take the exam: Midterm Exam (on Canvas) 06/20/2024 - 06/21/2024
8 Sets and Maps: 06/21/2024 - 06/24/2024

Overview

Not all data is intended to be treated as a sequence.

Associative containers, including sets (collections of items with no duplicates) and maps (lookup “tables” that can search for data associated with keys), can contribute to efficient and elegant application algorithms.

Activities

.

From this point on, the course materials are “under construction”.

  1. lecture Read: Sets and MultiSets Examine the generic Set…
  2. lecture Read: Maps and MultiMaps …and Map abstract classes and look at how we can use them in coding.
  3. video Watch Working with Sets & Maps

  4. video Watch Working with Sets & Maps
  5. lab Do: Under Construction Due: 06/24/2024

9 Hashing: 06/25/2024 - 07/02/2024

Overview

Hashing is a fast searching strategy for providing fast associative containers (sets and maps).

Hashing stores data in arrays (primarily), but does not store them in any predictable order, or even contiguously. Instead, hashing uses a special “hash function” to compute a desired location for any key we want to insert. If you don’t actually know the internal details of the hash function, its choices of locations would seem arbitrary, almost random.

Nonetheless, it works, and in many cases works well. Hash tables can often store and search for data in O(1) average time.

Activities
  1. lecture Read: Hashing
  2. reading Read Hashing, Ch 15
  3. lecture Read: Resolving Collisions
  4. lecture Read: Rehashing (Variable Hashing)
  5. lecture Read: Hash-Based Sets and Maps
  6. lab Do: Under Construction
  7. asst Do the assignment: Hashing Due: 07/02/2024

10 Search Trees: 07/03/2024 - 07/08/2024

Overview

Most of the data structures we have looked at so far have been devoted to keeping a collection of elements in some linear order.

Trees are the most common non-linear data structure in computer science.

Trees turn out to be exceedingly useful in searching. Properly implemented, a tree can be both searched and inserted into in O(log N) time. Compare this to the data structures we’ve seen so far, which may allow us to search in O(log N) time but insert in O(N), or insert in O(1) but search in O(N).

Activities
  1. reading Read Binary Trees, 12.1 … 12.14

  2. lecture Read: Binary Search Trees

  3. lecture Read: Traversing Trees with Iterators
  4. reading Read Weiss, Ch 12.2
  5. lecture Read: Balanced Search Trees
11 General Trees: 07/09/2024 - 07/14/2024

Overview

Trees are useful in representing things that naturally occur in hierarchies (e.g., many company organization charts are trees) and for things that are related in a “is-composed-of” or "contains manner (e.g., this country is composed of states, each state is composed of counties, each county contains cities, each city contains streets, etc.)

Activities
  1. reading Read General Trees, Ch 18, & 27.9

  2. lecture Read: Trees

  3. asst Do the assignment: Trees Due: 07/14/2024

12 Algorithm Design Techniques: 07/15/2024 - 07/19/2024

Overview

By this point in the semester, you’ve learned a lot of algorithms. Many practical problems can be solved by direct application of these. But what do you do when faced with an unfamiliar problem, one for which none of the “canned” algorithms in your personal toolbox are suitable?

When you have to design your own algorithms, you should consider some of the common patterns or styles that are available to you. This lesson looks at these styles, many of which we have seen before, and a few new ones as well.

13 Heaps and Priority Queues: 07/20/2024 - 07/25/2024

Overview

A priority queue is an ADT that allows us to repeatedly find and remove the largest (or smallest) item from a colleciton of data. They take their name from the idea that they implement a “queue” of items awaiting processing, but one in which some items have higher priority than others and so get to jump to the head of the line if nothing ahead has even higher priority.

Priority queues are generally implemented using heaps, a tree with very special ordering properties.

Activities
  1. reading Read Heaps, 12.16, 12.17
  2. lecture Read: Priority Queues
  3. lecture Read: Heaps
  4. lecture Read: Heapsort
  5. lab Do: Review the exam procedures and set up your proctoring for the Final exam. 07/18/2024
14 Graphs 07/26/2024 - 08/01/2024

Overview

A graph is a collection of vertices (nodes) connected by edges in arbitrary fashion. Graphs are used to represent data relationships that are far more complicated than could be represented using trees or lists.

Activities
  1. reading Read Graphs Ch 19
  2. lecture Read: Graphs --- the Basics
  3. lecture Read: Graphs --- ADT and Traversing

  4. lecture Read: Graphs --- Sample Algorithms
  5. video Watch Graph algorithms: traverse and min path

  6. selfassess Take the self-assessment: Graph Basics

  7. lecture Read: Sharing Pointers and Garbage Collection
  8. video Watch Graph algorithms: max-flow and min-cut

  9. asst Do the assignment: Graphs Due: 08/01/2024

15 Special Events and Dates
Activities
  1. exam Take the exam: Final exam (cumulative) 08/01/2024 - 08/02/2024
Symbol Key
conference Conference
slides Slides & Lecture Notes
text Textbook readings
exam Exam
lab Lab Assignment
asst Assignment
project Project
unix CS252 (Unix) Assignment

All times in this schedule are given in Eastern Time.