I have sequence of numbers (unsorted, no duplicate) with the target to sort them.
Approach 1: insert into vector. O(n), use sort algo and sort. O(nlogn)
Approach 2: insert into set. o(nlogn)
Which approach will be faster?
I feel set will be faster as every insertion in vector has to allocate complete array element and copy it an then delete it which may be expensive. But I read over web most of the place vector is over set.
Can anyone suggests me which one is faster with proper logic?
EDIT: if we don't know the no of element in advance which one will be faster set or vector (for both no of element are smaall andd no of elementt is large? note: if no of element is large set is better option it seems but is it good for small also? dont know)