Earlier quoted context omitted.
Big integer by default is a terrible idea. Just look at Python 3.
Python 2 was bigint by default. Not even going to deconstruct your argument past that
Nearly All Binary Searches and Mergesorts Are Broken (2006)
21–30 of 95 posts
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#22I wish it was worth a lot to be good at systems programming these days. It seems like the huge salaries are for rails senior devs. I spent like ten years getting really good at this stuff (the (low + high)/2 line jumped right out at me) but nowadays it feels like being really good at trivial pursuit. It's interesting how much things have changed in the last decade. I wonder what next decade's "Rails" will be? Could i…
I wish it was worth a lot to be good at assembly these days. It seems like the huge salaries are for c++ devs. I spent like ten years getting really good at this stuff but nowadays it feels like being really good at trivial pursuit. Edit: Did not mean to "mock" the OP, just merely trying to showing that you can apply that thought to almost anything in the programming world by replacing the technology/language names.
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#23The bug isn't in your algorithm; the bug is in your language, which doesn't provide arbitrary-precision integer arithmetic by default.
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#24Earlier quoted context omitted.
Are you mocking the parent poster? Why?
Nah, I thought it was a good point. It's easy to forget that we either change or become obsolete. It's one thing to know it abstractly, but it's hard to make any lifestyle changes, especially if it involves switching to a job in a completely new domain. http://thecodist.com/article/the_programming_steamroller_wai... is a good essay on this. EDIT: previous discussion: https://news.ycombinator.com/item?id=7204515
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#25I wish it was worth a lot to be good at systems programming these days. It seems like the huge salaries are for rails senior devs. I spent like ten years getting really good at this stuff (the (low + high)/2 line jumped right out at me) but nowadays it feels like being really good at trivial pursuit. It's interesting how much things have changed in the last decade. I wonder what next decade's "Rails" will be? Could i…
Just my guess.
http://www.newsweek.com/2017/04/21/quantum-computing-ibm-580...
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#26Earlier quoted context omitted.
Agreed completely; the right fix is that anything indexing an array should be an unsigned size_t (or equivalent for your language of choice).
Simply changing to size_t doesn't really fix this bug. You still have to use the low + (high - low) / 2 fix.
Of course sorting 2^63 elements would require the different calculation.
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#27The bug isn't in your algorithm; the bug is in your language, which doesn't provide arbitrary-precision integer arithmetic by default.
Erlang has arbitrary length integers by default, and I've found it to be incredibly liberating.
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#28I wish it was worth a lot to be good at systems programming these days. It seems like the huge salaries are for rails senior devs. I spent like ten years getting really good at this stuff (the (low + high)/2 line jumped right out at me) but nowadays it feels like being really good at trivial pursuit. It's interesting how much things have changed in the last decade. I wonder what next decade's "Rails" will be? Could i…
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#29Earlier quoted context omitted.
Nah, I thought it was a good point. It's easy to forget that we either change or become obsolete. It's one thing to know it abstractly, but it's hard to make any lifestyle changes, especially if it involves switching to a job in a completely new domain. http://thecodist.com/article/the_programming_steamroller_wai... is a good essay on this. EDIT: previous discussion: https://news.ycombinator.com/item?id=7204515
That's an amazing article. Thanks for sharing.
EDIT: I swear I did not read the top comment in the (newly) linked HN discussion of that article before I wrote my response. I agree completely.
Re: Nearly All Binary Searches and Mergesorts Are Broken (2006)
#30That may fix things in the case of searching a sorted array, but binary search can be used more generally than that. I think that fix might not work for some of the more general applications of binary search.
For instance, suppose f(n) is an increasing function from the signed integers to the signed integers, with f(a) 0, and you want to find an n in (a,b), if such n exists, such that f(n) = 0. Binary search on [a, b] is a reasonable approach.
If a 0, then that mid computation could overflow on the subtraction.