0
$\begingroup$

I'm taking the Design and Algorithms Part -II course in Coursera by professor Tim Roughgarden. In one of the classes, he mentioned that the running time for Dijkstra is $O(m \log n )$ using the heap data structure where $m$ is the number of edges and $n$ is the number of vertices. Also, he mentioned that using an exotic type of heap data structure the running time can be improved to $O(m + n \log n)$. I googled and couldn't find any relevant answers. It would be much helpful to know such data structures as its running time would be blazingly fast. Can anybody help?

$\endgroup$
9
  • 1
    $\begingroup$ Maybe he meant en.wikipedia.org/wiki/Fibonacci_heap ? $\endgroup$
    – nir shahar
    Commented Jun 8, 2021 at 16:26
  • $\begingroup$ As @nirshahar has stated, Fibonacci heaps are a way to improve the time complexity. however, as stated in the article, they are not "blazingly fast", only asymptotically faster (and difficult to implement). $\endgroup$
    – Nathaniel
    Commented Jun 8, 2021 at 16:54
  • $\begingroup$ @nirshahar . Seems like it. because the article says the fibonacci heap's worst case time complexity is O(a + b log n) where a = number of inserts, b = number of deletions, n = max size of heap. Here we would be inserting m number of edges into the heap and would do a deletion during each iteration which sums to n number of deletions and max size is the number of heap. In our case the maximum size is m - the number of edges. The last part is the only place where it seems different. By the definition it becomes O(M + N Log M). Anyway thanks. Will check whether modifications can be done. $\endgroup$ Commented Jun 8, 2021 at 17:05
  • $\begingroup$ @nirshahar I think the as there could be a maximum of quadratic number of edges in graphs corresponding to the number vertices. Thus m=n^2. Thus applying this in the time complexity found reduces O(M + N log M) => O(M + N Log N ^ 2) => O(M + 2 * N Log N) => O(M + N log N). $\endgroup$ Commented Jun 8, 2021 at 17:10
  • $\begingroup$ @Nathaniel thanks for information. Does Dijkstra's shortest path practically run faster in Fibonacci heap than using binary heap or is it slower ? How do they differ in Sparse and Dense graph. you have any suggestion ? $\endgroup$ Commented Jun 8, 2021 at 17:26

1 Answer 1

0
$\begingroup$

Thanks to @nirshahar for pointing out the data structure is Fibonacci heap with a worst case running time of O(a + b log n) where a = number of inserts, b = number of deletions, n = maximum size of the heap. For Dijkstra's algorithm for shortest path we have to insert M number of edges initially followed by n number of deletions in each iteration. Hence it worst case is O(m + n log m). In worst case for a dense graph m = n^2. Thus the worst case running time is transformed to O(m + n log n).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.