Top all-time · #21001
Tyler Hou
Personal blog · blog.tylerhou.io/postsprogrammingmath
Tyler Hou's personal blog at blog.tylerhou.io covers programming and math. Since 2022, 3 different Hacker News readers have linked it 4 times, most often “Binary Search, Revisited”. The last post was in 2024, but the archive is still widely read.
Too few sampled comments (2) to say how often HN recommends it.?
Why HN links it
HN readers link this blog's binary search post, which discusses the +1/-1 search optimization and whether a true/false invariant keeps the search theoretically pure. A followup post on other problems is also mentioned.
Summarised by Claude from a sample of 2 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- Binary Search, Revisited3 people · 3 mentions · first linked 2022-03-07
What Hacker News says?
> That said, you can only use the +1/-1 optimization when you are searching for a particular element, so you can no longer use a function that returns true/false; you need a third state to distinguish equality. So it's also not as theoretically "pure" as I would like. But not only is it less pure, it's also not applicable to other real problems (see the followup post: https://blog.tylerhou.io/posts/binary-search-rev…
Comment linking /posts/binary-search-revisited/
on “Binary search with confidence”Submitted Binary search with confidence as a story · 94 points
HN discussionI think you're right that I don't do the "normal" implementation quite enough justice; I've been meaning to write a third followup binary search post to "redeem" it. As others have mentioned, you can prove it correct with a simple invariant: the value that you are looking for is in the narrowed range (if it is in the array to begin with). But I think that invariant is harder to write code for, which is the point of…
Comment linking /posts/binary-search-revisited/
on “Binary search with confidence”Submitted Binary Search, Revisited as a story · 2 points
HN discussion