Chapter 3 Newtork Algorithms : SHORTEST PATH (Dijkstra ) Flashcards

1
Q

What does DIJKSTRAS algorithm do

A

Find the shortest path from A to all points in diagram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

2 steps to doing Dijskrta?

A

Stel 1 = labelling all the vertices

Step 2 = finding the path by working backwards that finds that minimum path

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What goes in a label for a vertex

A

Top left = the order of labelling
Top right = final value

In side = working out , where the final working value goes into top right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to label all the vertices step 1

A

1) start at the point , label this 1 and this has a working value 0

2) look at all routed going out from A, and ADD the weights to each boxes working value

3) now look for the next box with the SMALLEST WEIGHT in the box. Once identified , you have chosen this box

4) when a box is chosen label it with next number (2), and also write down the final working value in top right!

5) now , add all the weights going out from this box to whatver itsfinal working value is. IF THIS IS BETTER (SO SMALLER) than whatver is in the next box, write comma and out it in

Now go again, look for smallest working value box, and chose it

Eventually you will have everything labelled and thus all the distances

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Part 2 of Dijkstas

How to find the route then thst takes you to the smallest path

A

WORK BACKWARDS

  • start at the end post , and subtrsvt the weights from final working value .

If it gets you to the final working value of whatever successfully, pick this, if not it’s not part of route

Keep working backward and find the route

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Okay importsnt to remember, if you want to see which starting positions from 3 places will get to end point fastest, what’s modt effeicmt way of doing

A

Going from end point to three starting, because quickest from AV is same from VA

And doing this finds all 3 AT THE SAME TIME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Complexity dijkstras?

A

O(n2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly