# rec16 - Contents 1 Running Time of Dijkstra 1 2 Bounded...

This preview shows pages 1–3. Sign up to view the full content.

Contents 1 Running Time of Dijkstra 1 2 Bounded Integer Edge Weights 1 3 Single source, Single Target (SPP) 2 3.1 Early Termination: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3.2 Bi-directional Search: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3.3 Potentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1 Running Time of Dijkstra General Running Time: Initialization: O ( | V | ), Main loop: Every vertex requires exactly one Extract-Max (we can skip the Inserts if we assume we insert all vertices when they have equal keys of and therefore can insert them in any order). Each edge can require up to one Decrease-Key and it is possible to come up with a case in which every edge does require a Decrease-Key . Therefore, in terms of these operations the running time is O ( | V | ) T Extract-Min + O ( | E | ) T Decrease-Key . We would like Extract-Min and Decrease-Key to all be constant time... but as long as T Decrease-Key = o ( | V | ) and T Extract-Min = o ( | E | ), this is still probably better than Bellman-Ford! Data Structures: Structure Extract-Min Decrease-Key Running Time array O ( | V | ) O (1) O ( | V | 2 ) binary heap O (log | V | ) O (log | V | ) O ( | E | log | V | ) Fibonnacci heap O (log | V | ) amortized O (1) amortized O ( | V | log | V | + | E | ) Fibonnaci Heaps: Are not part of 6.006. Chapter 20 of CLRS talks about them if you are interested. 2 Bounded Integer Edge Weights Assume edge weights are non-negative integers bounded by C . Use an array of length | V | C + 1 for priority queue where vertices with paths of length i are stored in bucket i . Why does this work? Because all paths are less than ( | V | 1) C | V | C C + 1 | V | C + 1 possible path values. When you assign a path length to a previously unassigned node, you put it in its correct bucket. “ lives in | V | C . Algorithms: Decrease-Key ( v, k ) just moves vertex v from bucket key[ v ] to bucket k . 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Extract-Max 1 global curr-bucket // Initialize to zero at start of whole algorithm 2 while ( curr-bucket is empty) 3 curr-bucket curr-bucket +1 4 return First value in curr-bucket Correctness of Extract-Max : By induction. Do it yourself. Running Time of Decrease-Key and Extract-Min : Clearly Decrease-Key is O (1). In ad- dition, Extract-Max amortizes to O (1): over the course of the whole algorithm we see every bucket once. So, over the algorithm, the time of all calls to Extract-Max sums to O ( | V | C ). We extract each vertex once and only once so we make | V | calls to Extract-Max . Therefore, each call amortizes to O ( | V | C ) /O ( | V | ) = O (1).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern