Homework #2
due Wed 1/29
For each problem, develop an iterative algorithm to solve the problem using the 15-step process.
Write down each of the steps. (You can skip the implementation details and run
Questions
Observations
Once an algorithm has been found,
is it correct?
how much time does it take?
can we do better?
Section 0.2 raises two key points.
some functions grow much more quickly that
HW 2
2. basic steps
HW 2
- keep it basic!
Establishing the loop invariant often requires proper
initialization be sure to state what that initialization is!
strategy: compare element to maxsofar
bas
Iterative Algorithms.
Developing an Iterative Algorithm
.do repetition using loops.
Two main concerns:
figuring out what the repeated step is
convincingly arguing correctness
.solve problems by movi
HW 2
HW 4
Program captioning: assign employees to programs so that
no employees are assigned overlapping programs and the
fewest number of employees are used.
f(n) = (log n)(log n), g(n) = n/log(n)
T
HW 7
Developing Recursive Algorithms
Is the number of English words a fair measure of input
size?
establishing the problem
1. specifications
2. size
sums
brainstorming ideas
3. basic steps
i from 0
Patterns
Example
Graph coloring problem d+1 colors, at most d neighbors
Algorithms utilizing a particular approach (e.g. more of the
input) often have similar forms for some of the steps.
input elemen
HW 5
Dealing With Sums
The asymptotically faster algorithm takes longer when the
program is run. Why?
Sums arise in algorithm analysis when the amount of work
done increases or decreases with each loo
Example
Example
A sorted matrix is a 2D array of numbers such that the
numbers increase across each row and down each column.
(Assume all of the numbers are distinct no duplicates.)
Monster problem.
Homework #4
due Mon 2/3
1. Exercise 0.1, pages 8-9. Do parts (a)-(p). (Part (q) is optional.) Justify each of your
answers using the definitions of O, , and , and show your work. If you aren't familia
Homework #3
due Fri 1/31
For each problem, develop an iterative algorithm to solve the problem using the 15-step process.
Write down each of the steps. (You can skip the implementation details and run
Homework #5
due Wed 2/5
1. Alice and Bob each implement different algorithms for solving a particular problem.
When they run their programs, they find that the one with the asymptotically faster
algor
Homework #1
due Mon 1/27
Choose ONE of the following problems.
For your chosen problem, develop an iterative algorithm to solve the problem using the 15-step
process. Write down each of the steps. If
HW 3
Possible invariants:
left * right + result = x * y
result = product of y and the
number represented by the
rightmost k bits of the
binary representation of x
Stating these in combination
with t