71
Good performance is not just big O
(jmmv.dev)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
Besides an amazing anime, the heck is a big O?
Itcs a generalized method/notation of measuring how long a piece of code takes to run for a given input.
O(n^2^) means that as the input n grows, it takes exponential time to process. Like if you were trying to find items that matched in an array by looping over every item in the array and then using a nested loop in the first one to compare against every other item in the array. You'd be doing (# of items) * (# of items) comparisons, or (# of items)^2^ comparisons. n^2^ comparisons.
There's some rules about simplifying the result down to the most significant portion, so O^n^+n would be simplified as O^n^, but that's the basics.
It's a pretty important concept as you get into making larger projects.
this is really pedantic, but O(n^2^) is quadratic, not exponential. the exponential runtimes are things like O(2^n^). when n gets even modestly big (say n=100), youre looking at a difference of 2^100^ ≈ 1.26×10^30^ vs 100^2^ = 10,000. this is just to say that exponential runtime is really in a class of its own.
but otherwise i think this was a pretty good explanation of the concept
Its when you find the clitoris for the first time.
Joking aside, it's a description of the runtime of a thing for a size of a data set. Its expressed as a function. So for example an exponential function would get longer and longer as your data set size grows, linear time has a basically proportional operating time compared to the size of the data set, and log(n) would see runtime increase very little as data set size increases.