By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

Does a binary search work for odd number of elements ?

P: 1
Is binary search work for odd number OF element ?
Nov 15 '17 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,197
Yes. But you must always be sure to set your range correctly. Your end marker must point to one past the end element and not at the element itself or you will lose the end element in the search.
Nov 15 '17 #2

Expert 100+
P: 2,398
Are you using the stdlib bsearch() function or are you writing your own binary search function?
Nov 15 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.