Gistrec

Сomplexity

May 5th, 2018
278
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

There are three main notations to describe time complexity:

Big-O ("Big-Oh")
Big-Ω ("Big-Omega")
Big-ϴ ("Big-Theta")

Big-O notation provides an upper-bound on the number of operations performed
Big-Ω provides a lower-bound
Big-ϴ provides both an upper-bound and a lower-bound. In other words, Big-ϴ implies both Big-O and Big-Ω.

For our purposes, we will only consider Big-O notation because, in general, we only care about upper-bounds on our algorithms.


  1. "Constant Time" = O(1)
  2. "Logarithmic Time" = "Scales/Increases Logarithmically" = O(log n)
  3. "Polynomial Time" = "Scales/Increases Polynomially" = O(nk) (for any constant k)
  4. "Exponential Time" = "Scales/Increases Exponentially" = O(kⁿ) (for any constant k)
  5. "Factorial Time" = O(n!)

Below is a plot of various common time complexities, and it should be clear why the "bad" time complexities are considered so "bad".

alt text


Computational problems: P, NP, NP-Hard, and NP-Complete.

alt text


int a; // this variable can range from -2³¹ to +2³¹ - 1
long b; // this variable can range from -2⁶³ to +2⁶³ - 1
char c; // this variable can range from -2⁷ to +2⁷ - 1

unsigned int a; // this variable can range from 0 to +2³² - 1
unsigned long b; // this variable can range from 0 to +2⁶⁴ - 1
unsigned char c; // this variable can range from 0 to +2⁸ - 1

Comments
  • User was banned
Add Comment
Please, Sign In to add comment