NSG_SYPHER's blog

By NSG_SYPHER, history, 2 months ago, In English

PLs help me with the BELLMAN FORD ALGORITHM ERROR IN MY CODE(OUT OF BOUND ERROR) LINK-https://ideone.com/PHT2kj https://cses.fi/problemset/task/1671

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by NSG_SYPHER (previous revision, new revision, compare).

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The input is not 0-indexed.

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Bro can you tell me where it is incorrect? I can't figure it out

    • »
      »
      »
      2 months ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      src,des and wt can vary from 1 till n. Now in bellman ford function, you are writing "value[u]"; if u is equal to n then you will get out of bound error, because value vector is indexed from 0 till n-1.