andrewducker: (Default)
[personal profile] andrewducker

Date: 2017-06-22 08:55 am (UTC)
jack: (Default)
From: [personal profile] jack
I think that's the important thing. Knowing that an associative array is O(ok) and looking through an array is O(terrible) is the amount of knowledge you need in practice.

Most programmers never need to actually design an algorithm of this sort.

Date: 2017-06-22 10:04 am (UTC)
simont: A picture of me in 2016 (Default)
From: [personal profile] simont
Knowing that an associative array is O(ok) and looking through an array is O(terrible) is the amount of knowledge you need in practice

And don't forget the third clause, that looking through an associative array is O(godwhatareyouevendoing).

Date: 2017-06-22 10:19 am (UTC)
jack: (Default)
From: [personal profile] jack
:)

I wonder what the worst factors of unnecessary overhead are. There's plenty of examples of being O(n^2) when you could have been O(n) (surprisingly easy to do). And of being O(n) when you might be (1) as in these examples (when you really should notice something amiss).

I was also wondering if anyone's accidentally written a random-indexing (ie. generate a random number, if it's the desired index continue, else repeat), although that wouldn't have a worse complexity than a loop for a single index, even though it's clearly worse.

Date: 2017-06-22 10:30 am (UTC)
simont: A picture of me in 2016 (Default)
From: [personal profile] simont
A colleague of mine spotted a bug yesterday in a piece of test automation, in which a specification of a list of test cases had contained some tiny easy-to-miss lexical error (I forget exactly what, but something along the lines of putting an operator inside rather than outside a critical pair of parens) and as a result two long sublists of test cases had been fed to the Cartesian product operator instead of the concatenation operator.

It was only two lists being combined, fortunately, but the same sort of typo could just as easily have done the same thing to n lists, which would have turned a more or less linear amalgamation into an exponential one.

(Though I suppose the worse it gets, the more likely you are to actually notice when you investigate why the test system seems to be spending forever running indistinguishable variants of the test suite in question. Perhaps the real limiting factor on this question is not 'how egregious a consequence can you imagine for a trivial code error?' but 'how egregious a consequence can you imagine going undetected for some reason?'.)

June 2025

S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 121314
15161718192021
22232425262728
2930     

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 13th, 2025 07:53 am
Powered by Dreamwidth Studios