3.1.4 - Sorting algorithms Flashcards

(8 cards)

1
Q

Bubble sort

A

A bubble sort repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. This process continues until the list is sorted

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

Merge sort

A

A merge sort divides the list into halves, repeatedly sorts each half, and then merges the sorted halves back together to form a sorted list.

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

What are the advantages of a bubble sort?

A

Simple to understand and implement
Does not require additional memory

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

What are the disadvantages of a bubble sort?

A

Inefficient for large lists
Inefficient (slow) for large, unsorted datasets

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

What are the advantages of a merge sort?

A

Efficient (fast) for large, sorted lists

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

What are the disadvantages of a merge sort?

A

More complex to implement
Requires additional memory for the temporary arrays

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

When is a bubble sort more appropriate than a merge sort?

A

When working with small or nearly sorted datasets
Better for simpler datasets

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

When is a merge sort more appropriate than a bubble sort?

A

When dealing with large datasets where efficiency is crucial.

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