Merge sort and insertion sort Flashcards

(11 cards)

1
Q

What is merge sort?

A

• A sort that splits a list into halves
• Then merges them back in order

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

What type of approach does merge sort use?

A

• Divide and conquer

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

How does merge sort start?

A

• Split the list into smaller halves

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

When does merge sort stop splitting?

A

• When each sublist has one item

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

What happens after the splitting stage in merge sort?

A

• The sublists are merged back together in the correct order

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

What is an advantage of merge sort?

A

• Faster than simple sorts on large lists

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

What is a disadvantage of merge sort?

A

• Uses more memory
• More complex

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

What is insertion sort?

A

• A sort that takes each item and inserts it into the correct place in the sorted part on its left

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

How does insertion sort work?

A

• Start near the beginning
• Compare the current item with items to its left
• Insert it into the correct position

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

What is an advantage of insertion sort?

A

• Simple to understand

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

What is a disadvantage of insertion sort?

A

• Slow on large or badly ordered lists

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