Algorithm Complexities Flashcards

1
Q

What is the best case time complexity of all searching algorithms?

A

O(1) (because it is the found at the first item examined)

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

Average time complexity of a linear search?

A

O(n)

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

Average time complexity of a binary search on an array?

A

O(log n)

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

Average time complexity of a binary search on a tree?

A

O(log n)

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

Average time complexity of a hashing algorithm?

A

O(1)

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

Average time complexity of a breadth/depth first search

A

O(V + E) (vertices + edges, equivalent to O(n) )

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

Worst case time complexity of a linear search?

A

O(n)

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

Worst case time complexity of a binary search on an array?

A

O(log n)

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

Worst case time complexity of a binary search on a tree?

A

O(n)

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

Worst case time complexity of a hashing algorithm?

A

O(n) (because the value has been stored in the overflow table, so linear searches through all of its items)

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

Worst case time complexity of a breadth/depth first search

A

O(V^2) (vertices^2)

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

Best case time complexity of a bubble sort?

A

O(n)

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

Best case time complexity of an insertion sort?

A

O(n)

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

Time complexity in any case of a merge sort?

A

O(n log n)

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

Best case time complexity of a quick sort?

A

O(n log n)

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

Average time complexity of a bubble sort?

A

O(n^2)

17
Q

Average time complexity of an insertion sort?

A

O(n^2)

18
Q

Average time complexity of a quick sort?

A

O(n log n)

19
Q

Worst case time complexity of a bubble sort?

A

O(n^2)

20
Q

Worst case time complexity of an insertion sort?

A

O(n^2)

21
Q

Worst case time complexity of a quick sort?

A

O(n^2)

22
Q

Space complexity of a bubble sort?

A

O(1)

23
Q

Space complexity of an insertion sort?

A

O(1)

24
Q

Space complexity of a merge sort?

A

O(n)

25
Q

Space complexity of a quick sort?

A

O(log n)