Re: Which has faster access Binary Search of std::vector or std::set???

Discussion in 'C++' started by John H., Mar 1, 2010.

  1. John H.

    John H. Guest

    On Feb 27, 12:36 pm, "Peter Olcott" <> wrote:
    > Which has faster access Binary Search of std::vector or
    > std::set ???
    > I would gess that the former might be slightly faster and
    > take less memory.


    Binary search works on sorted data. The basic std::vector doesn't
    impose any sorting order on its contents, so you would have to sort
    them first (or insert them in a sorted manner). std::set forces its
    contents to be sorted, so it is always ready for binary search.
    Perhaps this is what Kaba was pointing out.
     
    John H., Mar 1, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zhang Le
    Replies:
    1
    Views:
    374
    Terry Reedy
    Mar 4, 2005
  2. Replies:
    8
    Views:
    1,940
    Csaba
    Feb 18, 2006
  3. sanborne
    Replies:
    5
    Views:
    2,026
  4. Bogdan

    Binary tree search vs Binary search

    Bogdan, Oct 18, 2010, in forum: C Programming
    Replies:
    22
    Views:
    3,096
    Michael Angelo Ravera
    Oct 21, 2010
  5. Replies:
    2
    Views:
    90
    Öö Tiib
    Mar 10, 2014
Loading...

Share This Page