R-1.2
Algorithm MaxsubSlow(A):
Input: An n-element array A of numbers, indexed from 1 to n.
Output: The maximum subarray sum of array A.
m 0 / the maximum found so far for j 1 to n do
for k j to n do
s 0 / the next partial sum we are computing for i j to
Breadth-First Search
5/7/2002 11:06 AM
Outline and Reading
Breadth-first search (6.3.3)
Breadth-First Search
Algorithm
Example
Properties
Analysis
Applications
L0
L1
A
B
C
L2
E
D
DFS vs. BFS (6.3.3)
F
Comparison of applications
Comparison of edge labels
5
FFT
11/27/2002 1:42 AM
Outline and Reading
Polynomial Multiplication Problem
Primitive Roots of Unity (10.4.1)
The Discrete Fourier Transform (10.4.2)
The FFT Algorithm (10.4.3)
Integer Multiplication (10.4.4)
Java FFT Integer Multiplication (10.5)
The Fa
Graphs
3/17/2005 2:11 AM
Outline and Reading
Graphs (6.1)
Graphs
1843
337
43
17
LAX
1233
ORD
802
SFO
Data structures for graphs (6.2)
DFW
Graphs
A vertex represents an airport and stores the three-letter airport code
An edge represents a flight route betw
Graphs
6/3/2002 1:41 PM
Outline and Reading
P and NP (13.1)
NP-Completeness
x1
x1
x2
x2
12
x3
x3
x4
22
x4
NP-completeness (13.2)
32
11
13
21
23
31
1
Running Time Revisited
NP-Completeness
2
Dealing with Hard Problems
Input size, n
To be exact, let n denot
Maximum Flow
5/13/2002 5:09 PM
Outline and Reading
Flow networks
Maximum Flow
v
4/6
3/3
s
w
1/1
3/5
u
5/13/2002 5:09 PM
Maximum flow
3/3
1/1
t
4/7
1/9
3/5
2/2
Maximum Flow
1
A weighted digraph G with nonnegative integer edge weights,
where the weight of a
R-1.2 Show that the MaxsubSlow algorithm runs in (n3) time.
To prove this question is equal to prove that n^3 is run time of Maxsubslow.
Quote from piazza: To show it's Big Omega, it would be nice if you could show that each of the
3 for-loops runs in at
188 views
note
Solutions Midterm 1 2005
By popular demand.
1. A sorting algorithm is stable if, in the output, elements with the same key preserve the relative order they had in the original sequence.
2.
We have n = 1000, N = 10300 , b = 1000 .
The number
147 views
note
Solutions Midterm 1 1998
Comments:
- the solutions of the other midterm have been posted on piazza too.
- The solution to exercises 3 and 6 are not unique, the others are.
1.
(a) 6 (e.g., right-most branch)
(b) 3 (e.g., left-most branch)
(c
CS 161, Eppestein
Homework 5
1. LA15, LA16, LA31, LA16, LA32, LA126, LA127, LA141, 162
2. A, E, I, M, N, K, O, P,L,H,D,C,B,A,F,A,E,I,G,J,I,K,D,L,K,I
3. If vertex d is our starting point, and it processes from d to c, d to a, and c to b. But d to a
isnt th
HW 3
1.
a. O(n log n)
b. Assumed - the array does not have to be sorted . Picking the the wrong pivot point
can cause the algorithm to run at O(n^2). ( 2,3,5,1,9,8,6,4,7) the middle index is 9 which is the
largest element in the array. When the array is p
HW 7
using Dijkstras algorithm
the shortest path from V->C is 3 but the correct answer is -1
this happens because weight -5 never gets relaxed because A is already removed from the
priority queue when A is pulled out from the priority queue each outgoing
Assignment #2
R-4.2
R-5.11
PreOrder: Yes order placed in
this order [1,2,5,3,4,6,7] results
in this tree. Traverse into
[1,2,3,4,5,6,7]
InOrder and PostOrder: No because the root is the smallest number in the heap but its is not
traverse first than the tr