Блог пользователя _QWOiNYUIVMPFSBKLiGSMAP_

Автор _QWOiNYUIVMPFSBKLiGSMAP_, история, 6 лет назад, По-английски

What is the complexity of dijkstra algorithm but without the vis array and without checking for dist array code https://ideone.com/VTaE03

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

What's the meaning of k in the code?

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

It can be quadratic, for example this directed graph:

Initial node is connected with k nodes (with cost 1), these k nodes are connected with another node (middle)(with costs k, k — 1 , k — 2..., 1). Middle node is connected with another k nodes (with cost 1), which are connected to the final node (with cost oo, a.k.a. big enough).

Certainly middle node will be visited k times, and visiting it requires k operations, as it has k neighbours. So total complexity would be at least .

  • »
    »
    6 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    If I understood the code correctly it wouldn't be difficult to construct O(2n) in a similar way.