I read about Big-O notation
Thus, any algorithm that is O (N) is also O (N ^ 2).
It seems to me that I donβt understand, I know that Big-O gives only the upper bound.
But as an O (N) algorithm, it is also an O (N ^ 2) algorithm.
Are there any examples where this is so?
I canβt think of anything.
Can anyone explain this to me?
"Upper bound" means that the algorithm takes no more (i.e. <=) that long (since the size of the input tends to infinity, taking into account the corresponding constant factors).
<=
, - .
, O (n) O (n log n), O (n 2), O (n 3), O (2 n), , n.
, .
O "".
, x < 4, , , x < 5 x < 6 ..
O (n) , n (n - , ), " n ".
, x :
x < k * n + C, K C -
, , n, k * n + C.
O (n ^ 2) , , kn ^ 2 + C. n - n ^ 2 >= n, . , x < kn + C, x < k * n ^ 2 + C.
, O (n) O (n ^ 2) O (N ^ 3) O (n ^ n) ..
big-O:
f(x) O(g(x)) iff |f(x)| <= M|g(x)| x >= x0.
f(x)
O(g(x))
|f(x)| <= M|g(x)|
x >= x0
, g1(x) <= g2(x), |f(x)| <= M|g1(x)| <= M|g2(x)|.
g1(x) <= g2(x)
|f(x)| <= M|g1(x)| <= M|g2(x)|
, - O (N), , N f (N) = k * N k. k * N ^ 2. , O (N) O (N ^ 2) , , O (N ^ m) m > 1.
* , N >= 1, N.
Big-O , , O (n) O (n ^ 2). O (n) O (n ^ 2) . , , . , O (n) alghoritm - O (n ^ 2) alghoritm, .
Source: https://habr.com/ru/post/1678450/More articles:Can I use Webpack to enter Google charts into my project? - javascriptPointing to a pointer in a safe manner - c ++A horizontal stack chart in python giving multiple charts in a Jupyter Notebook - pythonWhat are the limitations of the FUN function in H2O? - rIs the spark.yarn.containerLauncherMaxThreads property in the Spark Yarn configuration affect the overall runtime? - yarnPackage java.lang in java - javaHow to make bottom navigation display menu items with an icon and text, except for the center menu, show only an icon? - androidLaravel 5.4. Sending a message does not work. - phpRxJS dependency issue with Scheduler.async - angularIs there any way to export and excel sheet without copying to workbook? - vbaAll Articles