+ 1
How could i improve the code for the binarysearch?
2 Réponses
+ 3
It would be more readable if you used proper indenting and a function, so I recommend you start with that.
Drop the erase, it wrecks the purpose of a binary search. Instead use vars to keep track of front, mid and back.
Add support for numbers that do not exist.
After you get that implemented your next improvement could be the use of templates so you're not restricted to just ints.
Lastly drop the using namespace std; for a more professional look.
+ 1
thanks a lot! i will work on that