Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RyanOkamuro/e612ca2512a7a6ebdd2f5af296002579 to your computer and use it in GitHub Desktop.
Save RyanOkamuro/e612ca2512a7a6ebdd2f5af296002579 to your computer and use it in GitHub Desktop.
Big O Drills
Even or Odd: Constant time O(1) //doesn't matter what the input size is it doesn't effect the algorithm's run time
Are you here?: Polynomial time O(n^k) //has nested loops
Doubler: Linear time O(n) //Given input a and input b, where b is twice as large as a, it will take a linear algorithm twice as long to process b compared to a.
Naive Search: Constant time O(1) //doesn't matter what the input size is it doesn't effect the algorithm's run time
Creating pairs: Polynomial time O(n^k) //has nested loops
Computing fibonaccis: Constant time O(1) //doesn't matter what the input size is it doesn't effect the algorithm's run time
correct-----Linear time O(n) //Given input a and input b, where b is twice as large as a, it will take a linear algorithm twice as long to process b compared to a
An Efficient Search: Logarithmic time O(log(n)) //cut the problem size in half each round through
Random element: Constant time O(1) //doesn't matter what the input size is it doesn't effect the algorithm's run time
Is it prime?: Linear time O(n) //Given input a and input b, where b is twice as large as a, it will take a linear algorithm twice as long to process b compared to a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment