by eska · 3y ago · 0 comments
Often? Always! An algorithm always only works on a certain data data structure.
" Show me your tables, and I won't usually need your flowcharts;
they'll be obvious."
But to be fair, you need to be a pretty damn good comp sci person (and
actively thinking in algs and DS) to quickly look at DS and see the
"obvious" processing implied.Instead they wrote a horrible buggy mess that tries (and usually fails at least a little) to do the same thing as the obvious solution but with much more, and more convoluted, code.
I tend to use softer words like "often" as it makes folks feel less defensive towards the discussion. If someone came up to you and told you that your outlook on something is 100% definitively wrong, you might balk at the statement merely because I said "100%". Just as you have stated "Always!" and corrected me so emphatically.
Since I've found this to be a difficult topic for some, and given this is a public forum, I chose to be cautious in my wording.
`list.get_nth(n)` has O(N) runtime, as does `list.length()`, so binary search is actually completely possible, with runtime O(N^2) (aka "works very badly").
(Fair point that all four data structures need to be sorted, though, although ideally that would go without saying, since it's kind of inherent in what binary search is.)