Time Complexities Flashcards

1
Q

What is Constant time complexity?

A
  • O (1)
  • Time is independent of input
  • Example: Determining if a number is odd / even.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Linear time complexity?

A
  • O (n)
  • Worst case scenario: must go through each item once.
  • Example: Linear search
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Polynomial time complexity?

A
  • O (n²)
  • A loop inside a loop
  • Example: Bubble sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Logarithmic time complexity?

A
  • O (logn)
  • Halves the number of items in each iteration
  • Example: Binary search
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Linear Logarithmic time complexity?

A
  • O (nlogn)
  • N / A
  • Example: Merge sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an Exponential time complexity?

A
  • O (2^n)
  • Intractable
  • Example: Recursively calculating Fibonacci numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Factorial time complexity?

A
  • O (n!)
  • Intractable
  • Example: Travelers problem
How well did you know this?
1
Not at all
2
3
4
5
Perfectly