vthe time complexity for bubble, insertion, selection, merge and quick sorts Flashcards

(18 cards)

1
Q

What is the time complexity of bubble sort in the worst case?

A

O(n^2)

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

True or False: Insertion sort has a best case time complexity of O(n).

A

True

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

Fill in the blank: The average case time complexity for selection sort is ____.

A

O(n^2)

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

Which sorting algorithm has a worst case time complexity of O(n log n)?

A

Merge sort and Quick sort

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

What is the best case time complexity for merge sort?

A

O(n log n)

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

True or False: Quick sort can have a worst case time complexity of O(n^2).

A

True

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

What is the average case time complexity of bubble sort?

A

O(n^2)

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

In which sorting algorithm does the time complexity remain O(n^2) for both average and worst cases?

A

Selection sort

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

Fill in the blank: The time complexity of insertion sort in the worst case is ____.

A

O(n^2)

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

Which sorting algorithm is generally faster on average, quick sort or bubble sort?

A

Quick sort

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

What is the time complexity of quick sort in the average case?

A

O(n log n)

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

True or False: The time complexity of merge sort is always O(n log n).

A

True

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

Which sorting algorithm is stable: bubble sort or quick sort?

A

Bubble sort

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

What is the time complexity of insertion sort in the average case?

A

O(n^2)

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

Fill in the blank: The worst case time complexity for quick sort is ____.

A

O(n^2)

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

What is the primary advantage of merge sort over quick sort?

A

Merge sort is stable.

17
Q

Which sorting algorithm is typically used for small data sets due to its simplicity?

A

Insertion sort

18
Q

What is the time complexity of selection sort in the best case?