Robert Collins CSE586 CSE 586, Spring 2009 Advanced Computer Vision


 Hugo George
 7 months ago
 Views:
Transcription
1 CSE 586, Spring 2009 Advanced Computer Vision Dynamic Programming
2 Decision Sequences Let D be a decision sequence {d1,d2,,dn}. (e.g. in a shortest path problem, d1 is the start node, d2 is the second node you visit, and so on) Assume a cost function that tells how good a sequence of decisions is (e.g. could be the length of the path) Dynamic programming is a way of efficiently finding the optimal decision sequence, that is, the one with the lowest cost. (efficient = without having to compare all possible sequences)
3 Robert Collins Sample Graph Redrawn from Nodes. Directed edges with weights (costs). Start state (A). End state (J). Getting from A to J is an example of a sequence of decisions. At each node, you have to decide which arc to follow to get to another node A B C D E F G H I J 7
4 Sample Graph What are some paths from A to J in this graph? Each has an associated cost. A 2 2 B C E F H I 3 J D 5 G 3 Examples: A B E H J A C F H J A D E I J (Cost = 13) (Cost = 15) (Cost 2+++ = 1)
5 How Many Paths? Enumeration of paths in this example H J I E F G E F G B C D B C D B C D B C D B C D B C D A A A A A A A A A A A A A A A A A A Note, the tree structure here is only to methodically generate and visualize all paths. We are not doing tree search.
6 What is Shortest Path? J 3 H I E F G E F G B C D B C D B C D B C D B C D B C D A A A A A A A A A A A A A A A A A A We could evaluate cost for every path, then choose smallest. However, this would be intractable for larger graphs. Note: there are two solutions in this example.
7 Principle of Optimality If set of decisions D is optimal, then all proper subsequences of D are also optimal e.g. if ABCDE is shortest path from A to E, then BCD must be the shortest path from B to D Note: the converse is not true 2 B 1 C 1 A D 3 E 2
8 Verify Principle of Optimality To verify that the principle of optimality holds in a given problem, assume D is optimal is true, but that all subsequences are optimal is false, and try to derive a contradiction. We will use shortest path as an example: Suppose D={p1,p2,...,pn} is shortest path from p1 to pn, and that it contains a nonoptimal subpath {i,v1,,v2,j}. If {i,v1,,v2,j} is nonoptimal, then there is a shorter path from i to j, call it {i,z1,,z2,j}. But then {p1,...,i,z1,,z2,j,...,pn} would be a shorter path from p1 to pn than {p1,...,i,v1,,v2,j,...,pn} Therefore D was not the shortest path. Contradiction
9 Principle of Optimality The Principle of Optimality typically holds for cost functions that monotonically increase or decrease with each new decision For example, sums or products of all positive or all negative numbers.
10 Principle of Optimality is Source of Efficiency 3 J 1 H I E F G E F G B C D B C D B C D B C D B C D B C D A A A A A A A A A A A A A A A A A A Consider possibilities for subpath E J E H J : length E I J : length 8 principle of optimality
11 Principle of Optimality is Source of Efficiency 3 J H I E F G E F G B C D B C D B C D B C D B C D B C D A A A A A A A A A A A A A A A A A A Savings would be more dramatic for larger problems. Can often reduce an exponential problem, e.g. O(2 n ), to a polynomial time one, e.g. O(n 2 )
12 Robert Collins MultiStage Graphs A B C D E F G H I J Stage 1 Stage 2 Stage 3 Stage Stage 5 Has a natural 1D ordering by stage number related to concepts of partial ordering and topological sort Our sample graph has a special structure.
13 DP on MultiStage Graphs An obvious approach is to optimize multistage paths one stage at a time Forward approach: we can assume at stage k that we already know the optimal path from each node in stage k+1 to the goal state. Backward approach: we can assume at stage k that we already know the optimal path from the start state to each node in stage k1.
14 DP on MultiStage Graphs Forward approach: assume at stage k that we know the min cost path from each node in stage k+1 to the goal state. R1 MinCost(R1,Goal) Cost(Q,R1) R2 Q Cost(Q,R2) MinCost(R2,Goal) Goal Cost(Q,Rn) Rn Stage k Stage k+1 MinCost(Rn,Goal) MinCost(Q,Goal) = Min(Cost(Q,R1)+MinCost(R1,Goal), Cost(Q,R2)+MinCost(R2,Goal),, Cost(Q,Rn)+MinCost(Rn,Goal))
15 DP on MultiStage Graphs Backward approach: assume at stage k that we know the min cost path from each node in stage k1 to the start state. MinCost(Start,P1) P1 Cost(P1,Q) Start MinCost(Start,P2) P2 Cost(P2,Q) Q Cost(Pn,Q) MinCost(Start,Pn) Pn Stage k1 Stage k MinCost(Start,Q) = Min(Cost(P1,Q)+MinCost(Start,P1), Cost(P2,Q)+MinCost(Start,P2),, Cost(Pn,Q)+MinCost(Start,Pn))
16 DP on MultiStage Graphs Forward approach: we can assume at stage k that we already know the optimal path from each node in stage k+1 to the goal state. However, we then solve backwards, considering optimal path from nodes in stage n1 to goal, then from stage n2 to goal, and so on, until we find optimal path for the single start node in stage 1. Similarly, the Backward approach involves solving in the forward direction, starting at stage 1 and proceeding in increasing stages until reaching the goal node in stage n.
17 Example work through on board A 2 2 B 6 3 C E F H I 3 J D 5 G 3
18 Topological Ordering Although we have been looking at multistage graphs, it is not stages that matter. What is important is that we impose a topological ordering on the nodes such that Vi comes before Vj for i < j. A 2 2 B C E F H I 3 J D within a stage, we can impose an arbitrary ordering (C < B < D) 5 G 3 F < H H < J
19 Imposing Order DP can be used on more general graphs if we can impose a topological ordering. Directed Acyclic Graphs (DAG) can be trivially topologically ordered. We can impose an ordering on arbitrary graphs by some traversal method such as breadthfirstsearch (BFS) or depthfirst search (DFS). However, you have to verify that they impose an ordering that makes sense for the problem being considered. Coming up with a topological ordering is often the hardest part of dynamic programming.
20 Edit Distance Problem Statement: given two strings s1 and s2, edit distance is the minimum number of operations needed to change s1 into s2, where the valid operations are 1) change one letter to another 2) insert one letter 3) delete one letter Example: astrea to stereo has edit distance 3 0 astrea 1 strea ; delete letter a 2 sterea ; add letter e 3 stereo ; change a to o
21 Edit Distance Ordering An element of our graph is a pair (Ai,Bj) where Ai is a prefix string of s1 with length i and Bj is a prefix string of s2 with length j. Examples: (s1= astrea, s2= stereo ) (A2, B3) = ( as, ste ) (A, B1) = ( astr, s ) (A0, B0) = (, ) [null strings] etc...
22 Edit Distance Ordering For each set of prefix strings, there is a natural order A0 < A1 < A2 <... < An B0 < B1 < B2 <... < Bm Examples: (s1= astrea, s2= stereo ) (A2, B3) = ( as, ste ) (A, B1) = ( astr, s ) (A0, B0) = (, ) [null strings] etc... To extend to ordering of pairs, let (Ai,Bp) < (Aj,Bq) if p < q or ((p=q)&(i < j)) so ordering on B dominates ordering on A
23 Edit Distance Ordering For each set of prefix strings, there is a natural order A0 < A1 < A2 <... < An B0 < B1 < B2 <... < Bm Examples: (s1= astrea, s2= stereo ) (A2, B3) = ( as, ste ) (A, B1) = ( astr, s ) (A0, B0) = (, ) [null strings] etc... To extend to ordering of pairs, let (Ai,Bp) < (Aj,Bq) if p < q or ((p=q)&(i < j)) so ordering on B dominates ordering on A RASTER SCAN ORDER!
24 Dynamic Time Warping Computing edit distance is an example of a more general method called Dynamic Time Warping You want to compare two elements of two sequences, each of which might have extra or missing elements. Sequence 1 A B C D Sequence 2 A B D
25 Dynamic Time Warping Think of shifting two pointers along each string, element by element lefttoright, and deciding whether to compare the current elements or to skip one or the other of them. Sequence 1 i 1 Sequence 2 i 2
26 Dynamic Time Warping The indices i1, i2 can be thought of as indices in a 2D table Sequence 1 Sequence 1 Sequence 2 i 1 i 2 Sequence 2 I 1, I 2
27 Edit Distance Recurrence Relation Consider two strings astrea and stereo (A6,B6) What local edits can we do? (we will work from end of string backwards, but could develop the other way, equivalently) Skip letter at end of A Skip letter at end of B Match/Change last letters of A and B cost to skip one letter cost to edit astre into stereo cost(i,j) = 1 + cost(i1,j) cost to skip one letter cost to edit astrea into stere cost(i,j) = 1 + cost(i,j1) cost to change letter cost to edit astre into stere cost(i,j) = 1 + cost(i1,j1) cost(i,j) = 0 + cost(i1,j1) no cost if both letters match!
28 Edit Distance Keep a 2D matrix C(0.. s1, 0.. s2 ) to hold partial edit distance values. C(i,j) = dist(s1(1..i),s2(1..j)). %boundary conditions C(0,0) = 0; C(i,0) = i; %cost of skipping i letters from start of s1 C(0,j) = j; %cost of skipping j letters from start of s2 %recursive relation C(i,j) = min([ C(i1,j1) + (s1(i)!=s2(j)), %match, cost is 0 if same, %cost is 1 if different C(i1,j) + 1, %skip one letter from s1, cost is 1 C(i,j1) + 1]); %skip one letter from s2, cost is 1 Now compute and memoize from smallest substrings to largest.
29 Edit Distance Compute and memoize from smallest substrings to largest. %recursive relation C(i,j) = min([ C(i1,j1) + f(i,j), %match, cost f(i,j)=0 if same, 1 if different C(i1,j) + 1, %skip one letter from s1, cost is 1 C(i,j1) + 1]); %skip one letter from s2, cost is 1 i1,j1 i,j1 match cost = f(i,j) Skip letter from string 2 cost = 1 i1,j Skip letter from string 1 cost = 1 i,j
30 note: i is col variable. j is row variable. Edit Distance Example f(i,j) Letter match scores C(i,j) matrix entries %recursive relation C(i,j) = min([ C(i1,j1) + f(i,j), %match, cost f(i,j)=0 if same, 1 if different C(i1,j) + 1, %skip one letter from s1, cost is 1 C(i,j1) + 1]); %skip one letter from s2, cost is 1
31 Edit Distance Example (1) 1+1 f(i,j) Letter match scores C(i,j) matrix entries
32 Edit Distance Example (1) (1) f(i,j) Letter match scores C(i,j) matrix entries
33 Edit Distance Example (1) (1) (2) (3) () (5) f(i,j) Letter match scores C(i,j) matrix entries
34 Edit Distance Example (1) (1) (2) (3) () (5) 2+1 (2) 2+1 (2) 1+1 (1) 2+1 (2) 2+1 (3) () f(i,j) Letter match scores C(i,j) matrix entries
35 Edit Distance Example (1) (1) (2) (3) () (5) (2) (2) (1) (2) (3) () (3) (3) (2) (2) (2) (3) () () (3) (2) (3) (3) (5) (5) () (3) (2) (3) (6) (6) (5) () (3) (3) f(i,j) Letter match scores C(i,j) matrix entries Distance Is 3!
36 Edit Distance Example We now know that, upon making optimal edit decisions, our minimum edit distance is 3. However, we still don t know what the optimal sequence of decisions was. Two ways to recover the decision sequence: 1) recover what it was by reasoning backwards from the goal node. 2) annotate the decisions made as we fill in the cost table.
37 Edit Distance Example Alternative: Update algorithm to annotate decisions. %boundary conditions C(0,0) = 0; C(i,0) = i; decision is L(skip s1), go C(0,j) = j; decision is R(skip s2), go %recursive relation [C(i,j),argmin] = min([ C(i1,j1) + (s1(i)!=s2(j)), C(i1,j) + 1, C(i,j1) + 1]); If argmin==1 decision is M (match or change), go else if argmin == 2 decision is L (skip s1), go else if argmin == 3 decision is R (skip s2), go Endif
38 Edit Distance Example Memoize decisions. R R R R R R L L L L L L (1) (1) (2) (3) () (5) M M R R R R (2) (2) (1) (2) (3) () M M M R R R (3) (3) (2) (2) (2) (3) M M L M M R () () (3) (2) (3) (3) M M L M M M (5) (5) () (3) (2) (3) M M L L M R (6) (6) (5) () (3) (3) M M L L L M Letter match scores C(i,j) matrix entries
39 y x T x Example of DTW in Vision: Simple Stereo System z z y x P Epipolar line Left camera Right camera Same Y Coord!
40 Matching using Epipolar Lines Left Image Right Image For a patch in left image Compare with patches along same row in right image Match Score Values
41 Matching using Epipolar Lines Left Image Right Image Select patch with highest match score. Repeat for all pixels in left image. Match Score Values
42 Adding InterScanline Consistency Problem: matching each left image patch independently along the right epipolar line can lead to errors. We would like to enforce some consistency (smoothness) among matches in the same row. We also have to take into account occlusions, which are patches seen in only the left or the right image, but not both.
43 Disparity Space Image First we introduce the concept of DSI. The DSI for one row represents pairwise match scores between patches along that row in the left and right image. Pixels along right scanline Pixel j Pixels along left scanline Pixel i C(i,j) = Match score for patch centered at left pixel i with patch centered at right pixel j.
44 Disparity Space Image (DSI) Left Image Right Image Dissimilarity Values (1NCC) or SSD
45 Disparity Space Image (DSI) Left Image Right Image Dissimilarity Values (1NCC) or SSD
46 Disparity Space Image (DSI) Left Image Right Image Dissimilarity Values (1NCC) or SSD
47 Disparity Space Image (DSI) Left Image DSI Dissimilarity Values Enter each vector of match scores as a column in the DSI
48 Disparity Space Image Left scanline Right scanline
49 Start DSI and Scanline Consistency Assigning disparities to all pixels in left scanline now amounts to finding a connected path through the DSI End
50 Lowest Cost Path We would like to choose the best path. Want one with lowest cost (Lowest sum of dissimilarity scores along the path)???
51 Constraints on Path It is common to impose an ordering constraint on the path. Intuitively, the path is not allowed to double back on itself.
52 Ordering Constraint A B C D A B C A B C D D A B C D A B C D D A B C Ordering constraint and its failure
53 Dealing with Occlusions Left scanline Right scanline
54 Dealing with Occlusions Left scanline Right scanline Occluded from right scanline Match Match Match Occluded from left scanline
55 An Optimal Scanline Strategy We want to find best path, taking into account ordering constraint and the possibility of occlusions. Algorithm we will discuss now is from Cox, Hingorani, Rao, Maggs, A Maximum Likelihood Stereo Algorithm, Computer Vision and Image Understanding, Vol 63(3), May 1996, pp
56 Cox et.al. Stereo Matching Occluded from right i1,j1 i1,j Occluded from left match match Occluded from left i,j1 Occluded Three cases: from right Matching patches. Cost = dissimilarity score Occluded from right. Cost is some constant value. Occluded from left. Cost is some constant value. i,j C(i,j)= min([ C(i1,j1) + dissimilarity(i,j) C(i1,j) + occlusionconstant, C(i,j1) + occlusionconstant]);
57 Start Cox et.al. Stereo Matching Recap: want to find lowest cost path from upper left to lower right of DSI image. End At each point on the path we have three choices: step left, step down, step diagonally. Each choice has a welldefined cost associated with it. This problem just screams out for Dynamic Programming! (which, indeed, is how Cox et.al. solve the problem)
58 Robert Collins Real Scanline Example DSI DP cost matrix (cost of optimal path from each point to END) Every pixel in left column now is marked with either a disparity value, or an occlusion label. Proceed for every scanline in left image.
59 Example Result of DP alg. Black pixels = occluded.
60 Result of DP alg Example Result without DP (independent decisions)
61 Other DP Solutions All shortest paths problem find shortest path between any two nodes. 0/1 knapsack problem subset selection traveling salesman problem n! choices
Robert Collins CSE486, Penn State. Lecture 09: Stereo Algorithms
Lecture 09: Stereo Algorithms left camera located at (0,0,0) Recall: Simple Stereo System Y y Image coords of point (X,Y,Z) Left Camera: x T x z (, ) y Z (, ) x (X,Y,Z) z X right camera located at (T x,0,0)
More informationStereo Wrap + Motion. Computer Vision I. CSE252A Lecture 17
Stereo Wrap + Motion CSE252A Lecture 17 Some Issues Ambiguity Window size Window shape Lighting Half occluded regions Problem of Occlusion Stereo Constraints CONSTRAINT BRIEF DESCRIPTION 1D Epipolar Search
More informationProblem Set 7 CMSC 426 Assigned Tuesday April 27, Due Tuesday, May 11
Problem Set 7 CMSC 426 Assigned Tuesday April 27, Due Tuesday, May 11 1. Stereo Correspondence. For this problem set you will solve the stereo correspondence problem using dynamic programming, as described
More information1. Stereo Correspondence. (100 points)
1. Stereo Correspondence. (100 points) For this problem set you will solve the stereo correspondence problem using dynamic programming. The goal of this algorithm is to find the lowest cost matching between
More informationCS 787: Assignment 4, Stereo Vision: Block Matching and Dynamic Programming Due: 12:00noon, Fri. Mar. 30, 2007.
CS 787: Assignment 4, Stereo Vision: Block Matching and Dynamic Programming Due: 12:00noon, Fri. Mar. 30, 2007. In this assignment you will implement and test some simple stereo algorithms discussed in
More informationInfo 2950, Lecture 16
Info 2950, Lecture 16 28 Mar 2017 Prob Set 5: due Fri night 31 Mar Breadth first search (BFS) and Depth First Search (DFS) Must have an ordering on the vertices of the graph. In most examples here, the
More informationCIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018
CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018 Q1: Prove or disprove: You are given a connected undirected graph G = (V, E) with a weight function w defined over its
More informationComputer Science 385 Design and Analysis of Algorithms Siena College Spring Topic Notes: BruteForce Algorithms
Computer Science 385 Design and Analysis of Algorithms Siena College Spring 2019 Topic Notes: BruteForce Algorithms Our first category of algorithms are called bruteforce algorithms. Levitin defines
More informationElements of Dynamic Programming. COSC 3101A  Design and Analysis of Algorithms 8. Discovering Optimal Substructure. Optimal Substructure  Examples
Elements of Dynamic Programming COSC 3A  Design and Analysis of Algorithms 8 Elements of DP Memoization Longest Common Subsequence Greedy Algorithms Many of these slides are taken from Monica Nicolescu,
More informationCMSC 451: Dynamic Programming
CMSC 41: Dynamic Programming Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Sections 6.1&6.2 of Algorithm Design by Kleinberg & Tardos. Dynamic Programming
More informationUnit5 Dynamic Programming 2016
5 Dynamic programming Overview, Applications  shortest path in graph, matrix multiplication, travelling salesman problem, Fibonacci Series. 20% 12 Origin: Richard Bellman, 1957 Programming referred to
More informationDynamic Programming 1
Dynamic Programming 1 Jie Wang University of Massachusetts Lowell Department of Computer Science 1 I thank Prof. Zachary Kissel of Merrimack College for sharing his lecture notes with me; some of the examples
More informationSubset sum problem and dynamic programming
Lecture Notes: Dynamic programming We will discuss the subset sum problem (introduced last time), and introduce the main idea of dynamic programming. We illustrate it further using a variant of the socalled
More informationMemoization/Dynamic Programming. The String reconstruction problem. CS124 Lecture 11 Spring 2018
CS124 Lecture 11 Spring 2018 Memoization/Dynamic Programming Today s lecture discusses memoization, which is a method for speeding up algorithms based on recursion, by using additional memory to remember
More information1 Non greedy algorithms (which we should have covered
1 Non greedy algorithms (which we should have covered earlier) 1.1 Floyd Warshall algorithm This algorithm solves the allpairs shortest paths problem, which is a problem where we want to find the shortest
More informationLecture 3. Brute Force
Lecture 3 Brute Force 1 Lecture Contents 1. Selection Sort and Bubble Sort 2. Sequential Search and BruteForce String Matching 3. ClosestPair and ConvexHull Problems by Brute Force 4. Exhaustive Search
More informationCSC 505, Spring 2005 Week 6 Lectures page 1 of 9
CSC 505, Spring 2005 Week 6 Lectures page 1 of 9 Objectives: learn general strategies for problems about order statistics learn how to find the median (or kth largest) in linear averagecase number of
More informationDr. Amotz BarNoy s Compendium of Algorithms Problems. Problems, Hints, and Solutions
Dr. Amotz BarNoy s Compendium of Algorithms Problems Problems, Hints, and Solutions Chapter 1 Searching and Sorting Problems 1 1.1 Array with One Missing 1.1.1 Problem Let A = A[1],..., A[n] be an array
More informationCS 4495/7495 Computer Vision Frank Dellaert, Fall 07. Dense Stereo Some Slides by Forsyth & Ponce, Jim Rehg, Sing Bing Kang
CS 4495/7495 Computer Vision Frank Dellaert, Fall 07 Dense Stereo Some Slides by Forsyth & Ponce, Jim Rehg, Sing Bing Kang Etymology Stereo comes from the Greek word for solid (στερεο), and the term can
More information1 Dynamic Programming
Recitation 13 Dynamic Programming Parallel and Sequential Data Structures and Algorithms, 15210 (Spring 2013) April 17, 2013 1 Dynamic Programming Dynamic programming is a technique to avoid needless
More informationCoping with the Limitations of Algorithm Power Exact Solution Strategies Backtracking Backtracking : A Scenario
Coping with the Limitations of Algorithm Power Tackling Difficult Combinatorial Problems There are two principal approaches to tackling difficult combinatorial problems (NPhard problems): Use a strategy
More informationCS521 \ Notes for the Final Exam
CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit BigO ( ) Smallo ( ) Big ( ) Small ( ) Big ( ) Notes: ( ) ( ) ( ) ( )
More informationCSC 8301 Design and Analysis of Algorithms: Exhaustive Search
CSC 8301 Design and Analysis of Algorithms: Exhaustive Search Professor Henry Carter Fall 2016 Recap Brute force is the use of iterative checking or solving a problem by its definition The straightforward
More information2.3.4 Optimal paths in directed acyclic graphs
.3.4 Optimal paths in directed acyclic graphs Definition: A directed graph G = (N, A) is acyclic if it contains no circuits. A directed acyclic graph is referred to as DAG. circuit Problem Given a directed
More informationCS 170 DISCUSSION 8 DYNAMIC PROGRAMMING. Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17
CS 170 DISCUSSION 8 DYNAMIC PROGRAMMING Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17 DYNAMIC PROGRAMMING Recursive problems uses the subproblem(s) solve the current one. Dynamic
More informationSubsequence Definition. CS 461, Lecture 8. Today s Outline. Example. Assume given sequence X = x 1, x 2,..., x m. Jared Saia University of New Mexico
Subsequence Definition CS 461, Lecture 8 Jared Saia University of New Mexico Assume given sequence X = x 1, x 2,..., x m Let Z = z 1, z 2,..., z l Then Z is a subsequence of X if there exists a strictly
More informationSo far... Finished looking at lower bounds and linear sorts.
So far... Finished looking at lower bounds and linear sorts. Next: Memoization  Optimization problems  Dynamic programming A scheduling problem Matrix multiplication optimization Longest Common Subsequence
More informationPractice Problems for the Final
ECE250 Algorithms and Data Structures (Winter 2012) Practice Problems for the Final Disclaimer: Please do keep in mind that this problem set does not reflect the exact topics or the fractions of each
More informationAlgorithms for Data Science
Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Thursday, October 1, 2015 Outline 1 Recap 2 Shortest paths in graphs with nonnegative edge weights (Dijkstra
More information1 Dynamic Programming
Recitation 13 Dynamic Programming Parallel and Sequential Data Structures and Algorithms, 15210 (Fall 2013) November 20, 2013 1 Dynamic Programming Dynamic programming is a technique to avoid needless
More informationCSE 417 Branch & Bound (pt 4) Branch & Bound
CSE 417 Branch & Bound (pt 4) Branch & Bound Reminders > HW8 due today > HW9 will be posted tomorrow start early program will be slow, so debugging will be slow... Review of previous lectures > Complexity
More informationCSC 373 Lecture # 3 Instructor: Milad Eftekhar
Huffman encoding: Assume a context is available (a document, a signal, etc.). These contexts are formed by some symbols (words in a document, discrete samples from a signal, etc). Each symbols s i is occurred
More informationDynamic Programming Algorithms
CSC 364S Notes University of Toronto, Fall 2003 Dynamic Programming Algorithms The setting is as follows. We wish to find a solution to a given problem which optimizes some quantity Q of interest; for
More informationCS 350 Final Algorithms and Complexity. It is recommended that you read through the exam before you begin. Answer all questions in the space provided.
It is recommended that you read through the exam before you begin. Answer all questions in the space provided. Name: Answer whether the following statements are true or false and briefly explain your answer
More informationPractical Session No. 12 Graphs, BFS, DFS, Topological sort
Practical Session No. 12 Graphs, BFS, DFS, Topological sort Graphs and BFS Graph G = (V, E) Graph Representations (V G ) v1 v n V(G) = V  Set of all vertices in G E(G) = E  Set of all edges (u,v) in
More informationDynamic Programming Algorithms
Based on the notes for the U of Toronto course CSC 364 Dynamic Programming Algorithms The setting is as follows. We wish to find a solution to a given problem which optimizes some quantity Q of interest;
More informationStereo II CSE 576. Ali Farhadi. Several slides from Larry Zitnick and Steve Seitz
Stereo II CSE 576 Ali Farhadi Several slides from Larry Zitnick and Steve Seitz Camera parameters A camera is described by several parameters Translation T of the optical center from the origin of world
More informationCS 512: Comments on Graph Search 16:198:512 Instructor: Wes Cowan
CS 512: Comments on Graph Search 16:198:512 Instructor: Wes Cowan 1 General Graph Search In general terms, the generic graph search algorithm looks like the following: def GenerateGraphSearchTree(G, root):
More informationDynamic Programming (Part #2)
Dynamic Programming (Part #) Introduction to Algorithms MIT Press (Chapter 5) MatrixChain Multiplication Problem: given a sequence A, A,, A n, compute the product: A A A n Matrix compatibility: C = A
More informationAlgorithms Assignment 3 Solutions
Algorithms Assignment 3 Solutions 1. There is a row of n items, numbered from 1 to n. Each item has an integer value: item i has value A[i], where A[1..n] is an array. You wish to pick some of the items
More informationCS4495/6495 Introduction to Computer Vision. 3BL3 Stereo correspondence
CS4495/6495 Introduction to Computer Vision 3BL3 Stereo correspondence For now assume parallel image planes Assume parallel (coplanar) image planes Assume same focal lengths Assume epipolar lines are
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 6, 2016 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 7 April 6, 2016 洪國寶 1 Course information (5/5) Grading (Tentative) Homework 25% (You may collaborate when solving the homework, however when writing up
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a
More informationSTEREO BY TWOLEVEL DYNAMIC PROGRAMMING
STEREO BY TWOLEVEL DYNAMIC PROGRAMMING Yuichi Ohta Institute of Information Sciences and Electronics University of Tsukuba IBARAKI, 305, JAPAN Takeo Kanade Computer Science Department CarnegieMellon
More informationAlgorithms IV. Dynamic Programming. Guoqiang Li. School of Software, Shanghai Jiao Tong University
Algorithms IV Dynamic Programming Guoqiang Li School of Software, Shanghai Jiao Tong University Dynamic Programming Shortest Paths in Dags, Revisited Shortest Paths in Dags, Revisited The special distinguishing
More informationUNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list
UNIT4 Graph: Terminology, Representation, Traversals Applications  spanning trees, shortest path and Transitive closure, Topological sort. Sets: Representation  Operations on sets Applications. 1. Name
More information1 i n (p i + r n i ) (Note that by allowing i to be n, we handle the case where the rod is not cut at all.)
Dynamic programming is a problem solving method that is applicable to many different types of problems. I think it is best learned by example, so we will mostly do examples today. 1 Rod cutting Suppose
More informationStereo matching. Francesco Isgrò. 3D Reconstruction and Stereo p.1/21
Stereo matching Francesco Isgrò 3D Reconstruction and Stereo p.1/21 Structure of a stereo vision system Extract interesting point from each image Determine a set of matching points Compute the fundamental
More informationSolution for Homework set 3
TTIC 300 and CMSC 37000 Algorithms Winter 07 Solution for Homework set 3 Question (0 points) We are given a directed graph G = (V, E), with two special vertices s and t, and nonnegative integral capacities
More informationPSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : IV
PSD1A DESIGN AND ANALYSIS OF ALGORITHMS Unit : IV UNIT I  Introduction  Definition of Algorithm  Pseudocode conventions  Recursive algorithms  Time and space complexity  Big o notation 
More informationCSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT
CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT PROJECT 3 500 Internal Error problems Hopefully all resolved (or close to) P3P1 grades are up (but muted) Leave canvas comment Emails tomorrow End of quarter GRAPHS
More informationUndirected Graphs. DSA  lecture 6  T.U.ClujNapoca  M. Joldos 1
Undirected Graphs Terminology. Free Trees. Representations. Minimum Spanning Trees (algorithms: Prim, Kruskal). Graph Traversals (dfs, bfs). Articulation points & Biconnected Components. Graph Matching
More informationCMPSCI 311: Introduction to Algorithms Practice Final Exam
CMPSCI 311: Introduction to Algorithms Practice Final Exam Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more detail including
More informationIntroduction to Algorithms I
Summer School on Algorithms and Optimization Organized by: ACM Unit, ISI and IEEE CEDA. Tutorial II Date: 05.07.017 Introduction to Algorithms I (Q1) A binary tree is a rooted tree in which each node has
More informationStereo imaging ideal geometry
Stereo imaging ideal geometry (X,Y,Z) Z f (x L,y L ) f (x R,y R ) Optical axes are parallel Optical axes separated by baseline, b. Line connecting lens centers is perpendicular to the optical axis, and
More informationTopological Sort. Here a topological sort would label A with 1, B and C with 2 and 3, and D with 4.
Topological Sort The goal of a topological sort is given a list of items with dependencies, (ie. item 5 must be completed before item 3, etc.) to produce an ordering of the items that satisfies the given
More informationData Structures and Algorithms Week 8
Data Structures and Algorithms Week 8 Dynamic programming Fibonacci numbers Optimization problems Matrix multiplication optimization Principles of dynamic programming Longest Common Subsequence Algorithm
More informationUNIT 5 GRAPH. Application of Graph Structure in real world: Graph Terminologies:
UNIT 5 CSE 103  Unit V Graph GRAPH Graph is another important nonlinear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is onetomany relationship.
More informationGraph definitions. There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs. An undirected graph
Graphs Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs start Birmingham 60 Rugby fill pan with water add salt to water take egg from fridge
More informationDynamic Programming: Sequence alignment. CS 466 Saurabh Sinha
Dynamic Programming: Sequence alignment CS 466 Saurabh Sinha DNA Sequence Comparison: First Success Story Finding sequence similarities with genes of known function is a common approach to infer a newly
More informationSolving NPhard Problems on Special Instances
Solving NPhard Problems on Special Instances Solve it in poly time I can t You can assume the input is xxxxx No Problem, here is a polytime algorithm 1 Solving NPhard Problems on Special Instances
More informationPresentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Dynamic Programming
Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 25 Dynamic Programming Terrible Fibonacci Computation Fibonacci sequence: f = f(n) 2
More informationDepartment of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I
MCA 312: Design and Analysis of Algorithms [Part I : Medium Answer Type Questions] UNIT I 1) What is an Algorithm? What is the need to study Algorithms? 2) Define: a) Time Efficiency b) Space Efficiency
More informationGraph Representations and Traversal
COMPSCI 330: Design and Analysis of Algorithms 02/08/201702/20/2017 Graph Representations and Traversal Lecturer: Debmalya Panigrahi Scribe: Tianqi Song, Fred Zhang, Tianyu Wang 1 Overview This lecture
More informationSolutions to relevant spring 2000 exam problems
Problem 2, exam Here s Prim s algorithm, modified slightly to use C syntax. MSTPrim (G, w, r): Q = V[G]; for (each u Q) { key[u] = ; key[r] = 0; π[r] = 0; while (Q not empty) { u = ExtractMin (Q); for
More informationCS 170 Spring 2000 Solutions and grading standards for exam 1 Clancy
CS 170 Spring 2000 Solutions and grading standards for exam 1 Clancy Exam information 179 students took the exam. Scores ranged from 5 to 30, with a median of 16 and an average of 16.3. There were 19 scores
More informationCSE 331: Introduction to Algorithm Analysis and Design Graphs
CSE 331: Introduction to Algorithm Analysis and Design Graphs 1 Graph Definitions Graph: A graph consists of a set of verticies V and a set of edges E such that: G = (V, E) V = {v 0, v 1,..., v n 1 } E
More informationMinimum Spanning Trees Ch 23 Traversing graphs
Next: Graph Algorithms Graphs Ch 22 Graph representations adjacency list adjacency matrix Minimum Spanning Trees Ch 23 Traversing graphs BreadthFirst Search DepthFirst Search 11/30/17 CSE 3101 1 Graphs
More informationCS2 Algorithms and Data Structures Note 10. DepthFirst Search and Topological Sorting
CS2 Algorithms and Data Structures Note 10 DepthFirst Search and Topological Sorting In this lecture, we will analyse the running time of DFS and discuss a few applications. 10.1 A recursive implementation
More informationCOMP 558 lecture 22 Dec. 1, 2010
Binocular correspondence problem Last class we discussed how to remap the pixels of two images so that corresponding points are in the same row. This is done by computing the fundamental matrix, defining
More informationCS Algorithms and Complexity
CS 350  Algorithms and Complexity Dynamic Programming Sean Anderson 2/20/18 Portland State University Table of contents 1. Homework 3 Solutions 2. Dynamic Programming 3. Problem of the Day 4. Application
More informationCSE 421 Applications of DFS(?) Topological sort
CSE 421 Applications of DFS(?) Topological sort Yin Tat Lee 1 Precedence Constraints In a directed graph, an edge (i, j) means task i must occur before task j. Applications Course prerequisite: course
More informationn 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)
CSE 0 Name Test Fall 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to find the maximum of the n elements of an integer array is in: A.
More informationSearch Algorithms. IE 496 Lecture 17
Search Algorithms IE 496 Lecture 17 Reading for This Lecture Primary Horowitz and Sahni, Chapter 8 Basic Search Algorithms Search Algorithms Search algorithms are fundamental techniques applied to solve
More informationTrees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.
Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 7 April 15, 2015 洪國寶 1 Course information (5/5) Grading (Tentative) Homework 25% (You may collaborate when solving the homework, however when writing
More informationDynamic Programming II
June 9, 214 DP: Longest common subsequence biologists often need to find out how similar are 2 DNA sequences DNA sequences are strings of bases: A, C, T and G how to define similarity? DP: Longest common
More informationChapter 6. Dynamic Programming
Chapter 6 Dynamic Programming CS 573: Algorithms, Fall 203 September 2, 203 6. Maximum Weighted Independent Set in Trees 6..0. Maximum Weight Independent Set Problem Input Graph G = (V, E) and weights
More informationComputer Vision, Lecture 11
Computer Vision, Lecture 11 Professor Hager http://www.cs.jhu.edu/~hager Computational Stereo Much of geometric vision is based on information from (or more) camera locations hard to recover 3D information
More informationCSci 231 Final Review
CSci 231 Final Review Here is a list of topics for the final. Generally you are responsible for anything discussed in class (except topics that appear italicized), and anything appearing on the homeworks.
More information12/30/2013 S. NALINI,AP/CSE
12/30/2013 S. NALINI,AP/CSE 1 UNIT I ITERATIVE AND RECURSIVE ALGORITHMS Iterative Algorithms: Measures of Progress and Loop InvariantsParadigm Shift: Sequence of Actions versus Sequence of Assertions
More informationDEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNITIII. SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNITIII SUB CODE: CS2251 DEPT: CSE SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks) 1. Write any four examples
More informationIntroduction to Computer Science
Introduction to Computer Science CSCI 109 Readings St. Amant, Ch. 4, Ch. 8 China Tianhe2 Andrew Goodney Spring 2018 An algorithm (pronounced ALgorithum) is a procedure or formula for solving a problem.
More information1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18
CS 124 Quiz 2 Review 3/25/18 1 Format You will have 83 minutes to complete the exam. The exam may have true/false questions, multiple choice, example/counterexample problems, runthisalgorithm problems,
More informationHomework 2. Sample Solution. Due Date: Thursday, May 31, 11:59 pm
Homework Sample Solution Due Date: Thursday, May 31, 11:59 pm Directions: Your solutions should be typed and submitted as a single pdf on Gradescope by the due date. L A TEX is preferred but not required.
More information(Refer Slide Time: 05:25)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering IIT Delhi Lecture 30 Applications of DFS in Directed Graphs Today we are going to look at more applications
More information15451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015
15451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015 Dynamic Programming is a powerful technique that allows one to solve many different types
More informationSteven Skiena. skiena
Lecture 12: Examples of Dynamic Programming (1997) Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Give an O(n 2 )
More informationLecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions
U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front
More informationEfficient Sequential Algorithms, Comp309. Problems. Part 1: Algorithmic Paradigms
Efficient Sequential Algorithms, Comp309 Part 1: Algorithmic Paradigms University of Liverpool References: T. H. Cormen, C. E. Leiserson, R. L. Rivest Introduction to Algorithms, Second Edition. MIT Press
More informationDynamic Programming. Lecture Overview Introduction
Lecture 12 Dynamic Programming 12.1 Overview Dynamic Programming is a powerful technique that allows one to solve many different types of problems in time O(n 2 ) or O(n 3 ) for which a naive approach
More informationScribe: Virginia Williams, Sam Kim (2016), Mary Wootters (2017) Date: May 22, 2017
CS6 Lecture 4 Greedy Algorithms Scribe: Virginia Williams, Sam Kim (26), Mary Wootters (27) Date: May 22, 27 Greedy Algorithms Suppose we want to solve a problem, and we re able to come up with some recursive
More informationCopyright 2000, Kevin Wayne 1
Linear Time: O(n) CS 580: Algorithm Design and Analysis 2.4 A Survey of Common Running Times Merge. Combine two sorted lists A = a 1,a 2,,a n with B = b 1,b 2,,b n into sorted whole. Jeremiah Blocki Purdue
More informationLecture 14: Basic MultiView Geometry
Lecture 14: Basic MultiView Geometry Stereo If I needed to find out how far point is away from me, I could use triangulation and two views scene point image plane optical center (Graphic from Khurram
More information1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors
1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors on an EREW PRAM: See solution for the next problem. Omit the step where each processor sequentially computes the AND of
More informationDynamic Programming Homework Problems
CS 1510 Dynamic Programming Homework Problems 1. (2 points) Consider the recurrence relation T (0) = T (1) = 2 and for n > 1 n 1 T (n) = T (i)t (i 1) i=1 We consider the problem of computing T (n) from
More informationBasic Graph Definitions
CMSC 341 Graphs Basic Graph Definitions A graph G = (V,E) consists of a finite set of vertices, V, and a finite set of edges, E. Each edge is a pair (v,w) where v, w V. V and E are sets, so each vertex
More informationA virtual tour of free viewpoint rendering
A virtual tour of free viewpoint rendering Cédric Verleysen ICTEAM institute, Université catholique de Louvain, Belgium cedric.verleysen@uclouvain.be Organization of the presentation Context Acquisition
More information