Merge Sort Flashcards

1
Q

Merge sort is a stable sorting algorithm, which means it maintains the ___________________ in the input array

A

relative order of equal elements

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

What is the BEST case time complexity of Merge Sort, and when does it occur?

A

O(n log n), When the array is already sorted or nearly sorted.

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

What is the AVERAGE case time complexity of Merge Sort, and when does it occur?

A

O(n log n), When the array is randomly ordered.

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

What is the WORST case time complexity of Merge Sort, and when does it occur?

A

O(n log n), When the array is sorted in reverse order.

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

Why is merge sort suitable for parallel processing?

A

It independently merges subarrays

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

Merge sort is not an in-place sorting algorithm. What is the disadvantage of this?

A

It requires additional memory to store the sorted data.

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

Which is faster: merge sort or quick sort? Why?

A

Merge Sort is Slower than QuickSort in general as QuickSort is more cache friendly because it works in-place.

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

What sort of data structure is merge sort especially good at sorting?

A

Linked lists

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

______.sort in Java uses QuickSort while ______.sort uses MergeSort.

A

Arrays.sort; Collections.sort

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