Yr 2 Big O Notation Flashcards

(7 cards)

1
Q

What are the two categories that algorithms are analysed on?

A
  1. Time complexity
  2. Memory/storage complexity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is big O the most efficient, average efficiency or least efficient case of an algorithm.

A

Represents the worst case (least efficient).

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

What is the most efficient algorithm complexity (give an example).

A

O(1)
E.g. Hash tables

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

State the order of efficiency from most to least efficient.

A

O(1) - constant time
O(logn) - logarithmic time
O(n) - linear time
O(nlogn ) - Quasilinear time
O(n^2) - quadratic time
O(2^n) - exponential time
O(n!) - factorial time

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

What is the least efficient type of algorithm complexity (give an example)

A

Factorial time O(n!)
E.g. the heap

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

Give an example of an algorithm that has quasilinear time complexity. And why is this the case?

A

O(nlogn)
Mergesort
Because for each item in the list the list must be split

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

Give an example of an algorithm with time quadratic time complexity. And why is this the case?

A

O(n^2)
Bubble sort
Because the program loops through all list positions then for each list position loops through them all again

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