Dynamic programming(Dijkstra's Algo)

2,404 views

Published on

Djikstra's!

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,404
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
50
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dynamic programming(Dijkstra's Algo)

  1. 1. Dynamic Programming<br />Shortest Route Problem<br />
  2. 2. What is Dynamic Programming?<br />Dynamic programming is a methodology useful for solving problems that involve taking decisions over several stages in a sequence.<br />The term 'dynamic programming' refers to a general optimization technique useful for solving a class of multistage problems.<br /> Technique that divides the problem to be solved into a number of sub problems and then solves each sub-problem in such a way that the overall solution is optimal to the original problem. <br />
  3. 3. Djikstra’s Algorithm<br />Dijkstra's algorithm, conceived by Dutch computer scientistEdsgerDijkstra in 1956 and published in 1959,[1][2] is a graph search algorithm that solves the single-source shortest path problem for a graph with nonnegative edge path costs, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms.<br />Indeed, it is safe to say that the shortest path problem is one of the most important generic problem in such fields as OR/MS, CS and artificial intelligence (AI). One of the reasons for this is that essentially any combinatorial optimization problem can be formulated as a shortest path problem. Thus, this class of problems is extremely large and includes numerous practical problems that have nothing to do with actual ("genuine") shortest path problems.<br />Click Here for the Example<br />
  4. 4. Consider the following diagram where circles denote states, and lines between two such circles represent highways connecting the states. The numbers inside the circles represent state numbers, and those given beside the lines denote the distances between the states connected by the lines. The problem is to find the shortest route from state 1 to state 10 where the Bell Well temple is situated.<br />For a systematic approach to dynamic programming problem, consider the following notations.<br />n = number of stages.s = state variable.dsj = immediate distance from entering state s to existing state j.<br />Notice that the entire trip from state 1 to state 10 requires four stages (highways), regardless of the particular routing. Now, the problem is to select these four highways so that the total distance covered is least. The first highway has to be chosen from 1-2, 1-3, or 1-4, as 1 is the starting state. Likewise, the second highway has to be chosen from 2, 3, or 4, the third from 5, 6, or 7 and the fourth from 8 or 9. <br />
  5. 5. There is one table for each possible stage n, namely, n = 1, 2, 3, and 4. We start calculating distances between pair of states from stage 4 backwards. At the beginning of stage 4, we can be in either 8 or 9 (states). We note that state 10 is the only destination from both states 8 & 9. We summarize this information in the format below.<br />Stage 4 (n = 1)<br />Stage 3 (n = 2)<br />
  6. 6. Stage 2 (n = 3)<br />Stage 1 (n = 4)<br />The computations terminate in the above table with n = 4. The shortest route from state 1 to state 10 is given by 1-3-6-8-10, and the distance to be covered is 23.<br />

×