CPSC 327 Data Structures and Algorithms Spring 2010

# CPSC 327 Syllabus

Readings are to be done before the class period where they are listed. Dates for assignments shown in gray are tenative and are subject to change.

Assignments

### Week 1: 1/20-1/22

Topics: introduction; algorithm analysis

Wed

Fri Reading: Edmonds ch 23.1, 24 (review if you aren't familiar with the mathematics of logs and exponents), 25 (introduction and section 25.1 only), 26 (introduction and section 26.1 only)

Thinking Problem: An algorithm takes n English words as input. Is the number of words a fair measure of input size? Explain.

homework #1
due Mon 1/25 Wed 1/27

### Week 2: 1/25-1/29

Topics: algorithm analysis

Mon Notes: big-Theta

Wed Notes: big-Theta for sums, sums from algorithms homework #2
due Fri 1/29

Fri Notes: homework #1, sums from algorithms   project #1: Sort Analysis
due Fri 2/12 Wed 2/10

### Week 3: 2/1-2/5

Topics: iterative algorithms

Thinking Problem: Using example 1.4.3, write down code or pseudocode for an actual implementation of binary search. Point out how the code matches up with the 11 steps given. (What lines of code correspond to which of the steps?)

Notes: iterative algorithms

homework #3
due Wed 2/3

Wed Reading: Edmonds ch 2 homework #4
due Fri 2/5

Fri Reading: Edmonds ch 4, 5 (no thinking problem) homework #5
due Mon 2/8

### Week 4: 2/8-2/12

Topics: iterative algorithms; recursion and recurrence relations

Mon Notes: fractional knapsack, more of the output, narrowing the search space

Wed Reading: Edmonds ch 8, 9 (skip the discussions of running times in ch 9)

Thinking Problem: Construct a recursive algorithm for the task of finding the smallest element in an array. (Yes, I know there is a simple iterative algorithm. That's not the point here.) Write your algorithm in code or pseudocode, and demonstrate that you satisfied the checklist for recursive algorithms in section 8.5.

Thinking Problem: Do either #1 or #2 and any one of #3-#7 (two problems total) from exercise 27.1.1 (pages 400-401) - without looking at the solution in the back of the book.

Notes: recurrence relations

homework #6
due Mon 2/15

### Week 5: 2/15-2/19

Topics: recursion and recurrence relations; divide-and-conquer

Mon Reading: Edmonds ch 9 (the discussions of running times this time)

Thinking Problem: In general, having fewer subproblems and reducing the amount of work needed to create and combine subproblems will make a recursive algorithm run faster. But what about specific advice? Imagine that you've developed a recursive algorithm with a time T(n) = a T(n/b) + f(n). Would it be more productive to think about how to reduce the number of subproblems (as was done in the exponentiation, multiplication, and matrix multiplication examples) or how to reduce the work done splitting/combining? Does your answer depend on the particular equation for T(n)? If so, how?

Notes: messy sums

homework #7
due Wed 2/17

Wed Notes: T(n) = T(n/4)+T(3n/4)+n, designing recursive algorithms homework #8
due Fri 2/19

Fri Notes: designing recursive algorithms (recursive vs iterative spirit, min/max with 3n/2 comparisons, stock problem)   midterm #1
due Wed 2/24 in class

### Week 6: 2/22-2/26

Mon Notes: designing recursive algorithms (VLSI chip problem)

Wed Notes: designing recursive algorithms (recap of method, skyline, approaching a new problem) homework #9
due Fri 2/26

Thinking Problem: Categorize the ADTs presented in the reading according to how elements are positioned and the primary kinds of methods the collection supports:

• how elements are positioned: algorithmically (the ADT determines how elements are arranged) or manually (the user of the ADT has control over how elements are arranged)
• what methods the collection supports: determine if an element is a member of the collection, after/before (methods based on ordering of elements), access elements with highest priority, access elements at any position, access elements only at ends (first/last)

Notes:

homework #10
due Mon 3/1
project #2: Algorithm X
due Fri 3/12

### Week 7: 3/1-3/5

Mon Notes: homework #11
due Wed 3/3

Thinking Problem: exercise 10.4.1 (page 149), without looking at the solutions in the back of the book

Notes:

Thinking Problems:

1. Insert the elements 50, 60, 70, 20, 10, 25, 40, 30, 28 into an initially empty AVL tree, drawing the tree after each step.
2. Insert the elements 5, 16, 22, 45, 2, 10, 18, 30, 50, 12, 1 into an initially empty 2-4 tree, drawing the tree after each step.

Notes:

### Week 8: 3/8-3/12

Topics: implementing ADTs: more data structures

Mon Notes: homework #12
due Wed 3/10

Thinking Problems:

• How do you delete an element from a hashtable?
• How likely are collisions? Do a calculation: assuming that each day is equally likely as someone's birthday, what is the probability that there are no shared birthdays in a class of 30 students?
Notes:

### Week 9: 3/22-3/26

Topics: graphs and graph algorithms

Mon Notes: homework #13
due Fri 3/26

Wed Reading: Edmonds ch 14.1, 14.4-14.5

Thinking Problem: exercise 14.1.1 (page 178)

Notes:

Fri Reading: Edmonds ch 14.2-14.3, 14.6

Thinking Problem: exercise 14.3.3 #4, #5 only (page 188)

Notes:

homework #14
due Mon 3/29

### Week 10: 3/29-4/2

Topics: graph algorithms; greedy algorithms

Mon Notes:   project #3: Travel Agent
due Mon 4/12 Wed 4/14

Wed Reading: Edmonds ch 16.1, 16.2.3

Thinking Problem: exercise 16.1.1 (page 235) [justify your answer in the style of the proof in the chapter (a proof or a counterexample) - don't just state "yes" or "no"]

Notes:

Notes:

### Week 11: 4/5-4/9

Topics: greedy algorithms

Mon Notes: homework #15
due Wed 4/7

Wed Notes: homework #16
due Fri 4/9

Fri Notes:

### Week 12: 4/12-4/16

Topics: recursive backtracking / branch-and-bound

Thinking Problem: exercise 17.5.1 (page 265), without looking at the solutions in the back of the book

Notes:

homework #17
due Wed 4/14

Wed Notes:   midterm #2
due Mon 4/19 in class

Fri Notes:

### Week 13: 4/19-4/23

Topics: dynamic programming

Thinking Problems:

1. The book discusses turning a recursive backtracking algorithm into an iterative dynamic programming algorithm. Does a dynamic programming algorithm have to be iterative? That is, could you write it recursively without changing the big-Oh? Explain.
2. Where does the polynomial running time come from?

Notes:

homework #18
due Wed 4/21
project #4: TSP
due Tue 5/4

Thinking Problem: List two pieces of advice and/or strategies for developing dynamic programming algorithms.

Notes:

Notes:

homework #19
due Wed 4/28

### Week 14: 4/26-4/30

Topics: dynamic programming; reductions and complexity

Mon Notes:

Thinking Problem: exercise 19.8.1 (just explain how map the elephant problem to the graph problem, and how to turn a solution to the graph problem into a solution for the elephant problem - you do not need to repeat how to solve the graph problem)

Notes:

(optional)
homework #20
due Sun 5/9 4:30
handin by Thu 5/6 encouraged

Fri Reading: Edmonds ch 20 (read 20.2-20.3 just to get an overview of the ideas)

Thinking Problem: exercise 20.1.1 (choose three of the parts)

Notes:

### Week 15: 5/3-5/4

Topics: complexity

Mon Notes:

Sat