+ 1

How could i improve the code for the binarysearch?

https://code.sololearn.com/cStd88De16JM/?ref=app

30th Apr 2017, 10:07 PM
Jprom
Jprom - avatar
2 Answers
+ 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.
30th Apr 2017, 11:10 PM
Dennis
Dennis - avatar
+ 1
thanks a lot! i will work on that
30th Apr 2017, 11:15 PM
Jprom
Jprom - avatar