Docstoc

Algorithm Analysis Neil Tang 01222008

Document Sample
Algorithm Analysis Neil Tang 01222008 Powered By Docstoc
					               Dynamic Programming 1

                             Neil Tang
                             4/20/2010




CS223 Advanced Data Structures and Algorithms   1
                       Course Survey
              Please complete the course survey at:


       http://www.cs.montana.edu/survey/




CS223 Advanced Data Structures and Algorithms         2
                       Class Overview
 Basic Idea

 Fibonacci numbers

 Recursive equation evaluation

 All-pairs shortest paths




CS223 Advanced Data Structures and Algorithms   3
                           Basic Idea
 Mathematically express the problem in the recursive form.

 Solve it by a non-recursive algorithm that systematically
  records the answers to the subproblems in a table.




CS223 Advanced Data Structures and Algorithms                 4
                   Fibonacci Numbers
 fib(N) = fib(N-1) + fib(N-2)




CS223 Advanced Data Structures and Algorithms   5
                   Fibonacci Numbers




CS223 Advanced Data Structures and Algorithms   6
                   Fibonacci Numbers
 A dynamic programming based algorithm




Time Complexity: O(n)
CS223 Advanced Data Structures and Algorithms   7
            Recursive Equation Evaluation
            N 1
        2
C(N ) 
        N
             C (i)  N
            i 0




CS223 Advanced Data Structures and Algorithms   8
          Recursive Equation Evaluation




CS223 Advanced Data Structures and Algorithms   9
          Recursive Equation Evaluation
 A dynamic programming based algorithm




Time Complexity: O(n2)
CS223 Advanced Data Structures and Algorithms   10
              All-pairs Shortest Path
 The all-pairs shortest path problem: Given a weighted
  graph G, find the shortest (minimum cost) path between
  every pair of nodes in G.

 A simple solution: run Dijsktra’s algorithms |V| times, which
  leads to a time complexity of O(|E||V|log|V|).




CS223 Advanced Data Structures and Algorithms                 11
                All-Pairs Shortest Path
 Recursive expression for any node pair (i, j)

   Dk,i,j = min{Dk-1,i,j, Dk-1,i,k+Dk-1,k,j}




CS223 Advanced Data Structures and Algorithms     12
                                                  All-Pairs Shortest Path




                                                Time Complexity: O(|V|3)

CS223 Advanced Data Structures and Algorithms                          13

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:5/11/2013
language:English
pages:13