May I suggest adding to the article that binary search only works on sorted data? Someone trying to noodle this through from an outside perspective may struggle with understanding the algorithm if they don't start from a sorted perspective.
I agree, that would be helpful to put in the article. The classic phone book example makes it implicit (phone books are sorted) but I didn't say it explicitly. I'll modify the article to say it more clearly.
Thanks for the suggestion!
Ben
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
May I suggest adding to the article that binary search only works on sorted data? Someone trying to noodle this through from an outside perspective may struggle with understanding the algorithm if they don't start from a sorted perspective.
Hi Matt,
I agree, that would be helpful to put in the article. The classic phone book example makes it implicit (phone books are sorted) but I didn't say it explicitly. I'll modify the article to say it more clearly.
Thanks for the suggestion!
Ben