abh123's blog

By abh123, 11 years ago, In English

i am using upperbound and lowerbound in c++ regularly but i don't know actual algorithm behind this??? Plzz help..

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

| Write comment?
»
11 years ago, # |
  Vote: I like it +3 Vote: I do not like it

It's a simple binary search.

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it
  • »
    »
    11 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Actually i m not able to understand this step. std::advance (it,step);

    • »
      »
      »
      11 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      bcoz this step is linear and this will increase it's complexity..?

      • »
        »
        »
        »
        11 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        its just equal to it+step in our case, works for O(1)

        • »
          »
          »
          »
          »
          11 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          It's O ( 1 ) when you have random access iterators, on non random access iterators it has linear complexity.