Re:Binary search with confidence
by jjice on Monday March 07, 2022 @10:08AM
(#30588650)
> he found that ninety percent failed to provide a correct solution after several hours of working on it
I wonder how many university algorithms engineers would run into a similar situation with. I'm not very far out of university, so I have an unfair advantage, but take some engineers with at least 10 year experience and have them implement Dijkstra's by memory. Not saying this is necessarily a bad thing. If you're in industry for years, you have gained a lot more applicable knowledge to your work, kind of like how runners have a different kind of strength and muscle than weight lifers - they both meet their needs.
That said, I'm surprised at 90% overflowing code. Is it all in that midpoint calculation?
Re:Binary search with confidence
by mark-r on Monday March 07, 2022 @11:07AM
(#30589436)
Yes, it's always the midpoint calculation. Everybody forgets that (low+high) could overflow. It's trivial to work around once you know - just replace mid=(low+high)/2 with mid=low+(high-low)/2.
I wonder how many university algorithms engineers would run into a similar situation with. I'm not very far out of university, so I have an unfair advantage, but take some engineers with at least 10 year experience and have them implement Dijkstra's by memory. Not saying this is necessarily a bad thing. If you're in industry for years, you have gained a lot more applicable knowledge to your work, kind of like how runners have a different kind of strength and muscle than weight lifers - they both meet their needs.
That said, I'm surprised at 90% overflowing code. Is it all in that midpoint calculation?