Sportsman's blog

By Sportsman, history, 4 years ago, In English

I recently came across the Bellman-ford algorithm and tried to understand the intuition behind, why the Bellman-Ford algorithm takes atmost V-1 iterations to give the correct ouput. It would be helpful if you could share the reason or probably a test case or both, so that i can do a dry run to digest it. Thanks!

Full text and comments »

  • Vote: I like it
  • -23
  • Vote: I do not like it

By Sportsman, history, 4 years ago, In English

We all know that we can also use sort function for a specific portion of a vector. Eg: let a vector be v = {24, 11, 5, 7, 6} , now if we want to sort only last three elements, we can write sort(v.begin()+2,v.end()) Likewise, I thought we can also use lower_bound(v.begin()+2,v.end(),6) to find the lower_bound for 6 in the last three elements. But that's not working. May i please know where I'm going wrong . It seems the lower_bound and upper_bound functions only work for the whole vector despite our attempts & wants. Please correct me if I'm wrong.

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it