_QWOiNYUIVMPFSBKLiGSMAP_'s blog

By _QWOiNYUIVMPFSBKLiGSMAP_, history, 6 years ago, In English

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

| Write comment?
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What's the meaning of k in the code?

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

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