Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
dataflow
on Nov 6, 2022
|
parent
|
context
|
favorite
| on:
Nearly all binary searches and mergesorts are brok...
Nope, try low = 1, high = 1 and you get mid = 0.
benmmurphy
on Nov 6, 2022
[–]
i think you can fix it with: (low >> 1) + (high >> 1) + (low & 1 & high)
for unsigned numbers. not sure if it works for signed numbers.
Join us for
AI Startup School
this June 16-17 in San Francisco!
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: