Basic algorithmic concepts ---
Lecture1,
Lecture2,
Lecture3
- correctness of an algorithm
- worst-case running time as a function of input size
- example: Euclid's algorithm
Mathematics --- Lecture3, Lecture4
- Links: S04_CS141:GeometricSums, S04_CS141:BoundingSums, S04_CS141:RecurrenceRelations
- O-notation, Θ(), Ω()
- How do you tell whether a sum is a geometric sum?
- Is a geometric sum proportional to its largest term?
- Is this a geometric sum: ∑i=1..n i2?
- Is that sum proportional to its largest term?
- Give the best big-O upper bound you can on ∑i=1..n i log i.
- Give the best big-Θ lower bound you can on ∑i=1..n i log i.
- Describe the recursion trees for the following recurrences:
- T(n) = 3T(n-3); T(0) = 1;
- S(n) = 3S(n/3); T(0) = 1;
- For each tree, what is the depth and how many children does each node have?
- Give the best O and Θ bounds you can on T(n) and S(n).
S04_CS141:CountingPathsByDP --- Lecture5
- Draw a directed acyclic graph with 10 vertices, choose a source vertex, and label each vertex with the number of paths from the source to that vertex.
- Describe a linear-time algorithm for doing this in arbitrary directed acyclic graphs.
S04_CS141:FibonacciByDP --- Lecture5
- Describe the recursion tree for the following algorithm:
- 1. int fib(n) { if (n<= 1) return n; return f(n-1)+f(n-2); }
- Argue that the depth of the tree is at least n/2 and at most n.
- Argue that the running time of the algorithm is at least 2n/2.
- Describe an algorithm running in O(n) time for computing the n'th fibonacci number.
- Argue that it runs in O(n) time.
S04_CS141:NChooseKByDP --- Lecture5
- Define "n choose k" = C(n,k).
- Give a recurrence relation for C(n,k).
- Describe an algorithm running in O(nk) time for computing C(n,k).
S04_CS141:SubsetSumByDP --- Lecture6, (Repository)
- Define the subset sum problem.
- Describe a dynamic programming algorithm for the problem.
- What is the running time?
- What is the underlying recurrence relation?
Longest ascending subsequence, Longest common subsequence (book section 11.5)
S04_CS141:Graphs
- Know the following terms: neighbor, path, cycle, tree, connected graph, connected component, vertex degree.
S04_CS141:DepthFirstSearch --- Lecture9
- By hand, run DFS on some undirected and directed graphs. Show the resulting DFS tree and the DFS numbering.
- In an undirected graph, explain why DFS does not classify any edges as cross edges or forward edges.
- What is the worst-case time complexity of DFS on a graph with n nodes and m edges?
- Justify your answer. Give a clear argument bounding the time taken by DFS in terms of n and m.
S04_CS141:CutVerticesByDFS --- Lecture10
- What is the definition of a cut vertex?
- Define what the low numbers are, in the algorithm for finding cut vertices.
- How can you tell whether a vertex is a cut vertex by looking at the low numbers?
- Give a recurrence relation for the low numbers.
- Explain how to use that recurrence relation to find cut vertices in linear time.
S04_CS141:DiGraphs, S04_CS141:DFSInDiGraphs
S04_CS141:CyclesByDFS
- Prove that a directed graph has a cycle if and only if DFS will classify some edge of the graph as a back edge.
S04_CS141:TopologicalSortByDFS
- Define topological ordering of a directed acyclic graph.
- Give an example.
- If you order the vertices by DFS number, does that always give a topological ordering?
- Define the DFS post-order numbering.
- Give pseudo-code to compute the DFS post-order numbering.
- If you order the vertices by DFS post-order number, does that always give a topological ordering?