IanDCarroll / BigO

Python examples of big O and performance of algorithms at scale
MIT License
1 stars 0 forks source link

O(N^2) #1

Closed kammitama5 closed 7 years ago

kammitama5 commented 7 years ago

O(N^2) is a quadratic time complexity graph, or squared (n n or i j) (ie worst case), not times two.

I really enjoy your Scrum notes and your Github in general, btw :) Also, this is neat. My prof showed us this in Java class :) https://www.toptal.com/developers/sorting-algorithms/

IanDCarroll commented 7 years ago

Very cool! I really like the graphics!

Oh, so you mean O(N^2) is squared, not simply twice. That would explain the ^2 part. I think I meant that. Thanks for the catch.

Dare I ask, why mention "Quadratic time complexity graph"? What detail does that add that "Squared" does not?

kammitama5 commented 7 years ago

Meee tooo!! Haha I think you probably meant that too! Oh...I guess I think about it in terms of a quadratic function...I've been doing some Matlab and laTeX lately (plus reading Math Overflow/TeX overflow and nLab. nLab is a great resource! (=>https://ncatlab.org/nlab/show/algebra+for+an+endofunctor ).

so thinking of everything as matrices...as my friend would say; in FORTRAN, such a function would be something like a column matrix (if you have a matrix of 2x2 {2 2 3 3) how would you get one of the 3s? In most programming languages you'd have to do a nested for-loop..for i in j..where i gets the outer loop/row or 2 2 and 3 is the inner loop(column), hence an n squared complexity) or a nested function(for i in j..for i in j). for (i = 0; i < N; i++) { for (j = i+1; j < N; j++) { sequence of statements } } http://pages.cs.wisc.edu/~vernon/cs367/notes/3.COMPLEXITY.html

The term is quadratic time according to wiki, but it's essentially the same thing as alluding to n squared. " (quadratic [which is just a math-y way of saying "squared"] vs linear)" https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html

whoops..do I close it now? Hope all is well :)

IanDCarroll commented 7 years ago

Oh, no. I'll close it when I've updated the readme for accuracy. :smile:

IanDCarroll commented 7 years ago

@kammitama5 thanks! I think that really improved the readme!