Big-O notation explained by a self-taught programmer
justin.abrah.ms
Big-O notation explained by a self-taught programmer
1–10 of 80 posts
Re: Big-O notation explained by a self-taught programmer
#2Re: Big-O notation explained by a self-taught programmer
#3SELECT a, b, c FROM abc (30,000 rows)
BEGIN
SELECT e, d, f FROM edf WHERE e = a (30k * 1m)
BEGIN
SELECT x, y, z FROM xyz WHERE d = x (30k*1m*500k scanned)
BEGIN
process()
END
END
ENDA customer or manager can all find respect in lowering the growth rate of a query. No mathematics required. Simply, "Your report now runs in 30 seconds instead of 20 minutes." Anyone can compute that!
The mathematics of Big-O gets annoying for average case scenarios. Instances of
def fun(abc):
l=[]
for x in abc:
if x%2==0:
for y in abc:
l.append(y)
return lRe: Big-O notation explained by a self-taught programmer
#4That said, I got ~500 gumballs in the machine ((container diameter / gumball diameter)^3 * .64) so both guesses of 100 and 1000 should be within an order of magnitude. ;)
Re: Big-O notation explained by a self-taught programmer
#5You can actually see about 100 gumballs in the picture, so there must be far more hidden behind them -- my guess is closer to 500, which is about twice as close (in order-of-magnitude) to 1000 as to 100.
Re: Big-O notation explained by a self-taught programmer
#6To be clear, I really appreciate the writeup. I just wish it had been framed better. It should be clear that this is for beginner programmers, regardless of whether they have a degree or whether they're self-taught.
Re: Big-O notation explained by a self-taught programmer
#7One thing I would stay away from is the talk about "orders of magnitude" because the order of a function and an order of magnitude are very different topics, and it could cause a reader to make bad conclusions like "one algorithm takes 10 seconds to run, one take 100 to run, they must have different big-O notation". I understand why the analogy is made, it's because you're estimating things from a high level, but I think it could cause confusion on the fundamentals.
Re: Big-O notation explained by a self-taught programmer
#8Re: Big-O notation explained by a self-taught programmer
#9It's a different meaning of "order", that has to do with the shape of the size-vs-time curve. It's the same meaning as the order of a polynomial ("x" is linear or 1st order, "x^2" is quadratic or 2nd order, etc).
but Big-O is all about the approximate worst-case performance of doing something.
It can be, but I think it's more commonly taken to mean the average case. One example is quicksort, which is O(n*log(n)) on average but can be quadratic (n^2) in the worst case.