3
Assuming that the binary search works only with array of ordered integers, if I had to search for an integer in an ordered vector the speed of the search would be much faster than a sequential search, but my question is, if my vector is not ordered how much would it influence the speed in relation to sequential search if I had to sort it? and if we can go deeper think of a binary search on a String vector the process would be:
- Convert each vector item to a decimal number
- Sort the vector
- Perform the binary search
In these two examples how much would influence the speed in relation to sequential search processes before binary search?
It depends on the amount of searches you will perform after sorting. If there are few searches it is not worth it.
– user4552