Big O Notation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the rankings for the big O notation for time complexity ? (with the highest rank being the fastest)

A

O(1) - Constant
O(log n) - Logarithmic
O(n) - Linear
O(n log n) - Linearithmic
O( n^2) - Polynomial
O(2^n) - Exponential

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

State the purpose of Big O notation

A
  • Evaluate the complexity of an algorithm
  • Show how the time / memory / resources increase as the data size increases
  • Evaluate worst case scenario for an algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain what is meant by Time Complexity

A

How the times scales as data size increases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain what is meant by Space Complexity

A

How much memory the algorithm needs as the data size increases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain O(1)

A

Always executes in the same amount of time regardless of the size of the data set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain O(log n)

A

Halves the data set in each pass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain O(n)

A

As the number of items in data set increase, the time it takes to complete the action increases by same amount

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain O(n^2)

A

Performance is proportional to the square of the size of dataset. Reduces efficiency with larger datasets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain O(2^n)

A

Doubles the dataset when an item is added to the dataset

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the best, average, worst case time complexities for linear search

A
  • Best = O(1)
  • Average = O(n)
  • Worst = O(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the best, average, worst case time complexities for binary search

A
  • Best = O(1)
  • Average = O(log n)
  • Worst = O(log n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the best, average, worst case time complexities for binary search tree

A
  • Best = O(1)
  • Average = O(log n)
  • Worst = O(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the best, average, worst case time complexities for hashing

A
  • Best = O(1)
  • Average = O(1)
  • Worst = O(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the best, average, worst case time complexities for bubble sort

A
  • Best = O(n)
  • Average = O(n^2)
  • Worst = O(n^2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the best, average, worst case time complexities for insertion sort

A
  • Best = O(n)
  • Average = O(n^2)
  • Worst = O(n^2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the best, average, worst case time complexities for merge sort

A
  • Best = O(n log n)
  • Average = O(n log n)
  • Worst = O(n log n)
17
Q

What are the best, average, worst case time complexities for quick sort

A
  • Best = O(n log n)
  • Average = O(n log n)
  • Worst = O(n^2)
18
Q

What are the space complexities for the SORTING ALGORITHMS

A
  • Bubble Sort = O(1)
  • Insertion Sort = O(1)
  • Merge Sort = O(n)
  • Quick Sort = O(log n)