abh123's blog

By abh123, 12 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?
»
12 years ago, # |
  Vote: I like it +3 Vote: I do not like it

It's a simple binary search.

»
12 years ago, # |
  Vote: I like it 0 Vote: I do not like it
  • »
    »
    12 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);

    • »
      »
      »
      12 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..?

      • »
        »
        »
        »
        12 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)

        • »
          »
          »
          »
          »
          12 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.