Sorting algorithms Flashcards

1
Q

What are the different types of sort algorithms?

A

Bubble sort
Insertion sort
Merge sort

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

How does a bubble sort work?

A

It is quite simple in how in works:

It repeatedly steps though a list of data, comparing each pair of data it comes across and swaps their placements if their order is wrong

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

How does an insertion sort work?

A

It is quite simple in how it works, but is more efficient than a bubble sort:

It steps through a list of data and for each item it finds it compares it with all the previous items of data. If it is smaller than a previous piece of data, it is swapped and the next digit back is compared with the same data value

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

How does a merge sort work?

A

It is the most complex sort, but also the quickest:

  1. It starts with a list of data to be sorted
  2. The data is split into pairs, which are then compared and sorted
  3. Each pair is then compared with the next pair along and sorted, creating sets of 4
  4. This is repeated until all the data is back in one set
How well did you know this?
1
Not at all
2
3
4
5
Perfectly