2.3.1 Sorting Flashcards

1
Q

What is Bubble sort

A

Bubble sort compares adjacent elements with each other, if they found in the wrong order the algorithm will swap them, if not the algorithm will move on to the next adjacent elements

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

What is insertion sort?

A

It compares each item with the previous one.
- if it’s greater than the previous element it will be inserted back to it place.
- if its smaller than the previous item, it will be compare with the item 2 position back.
- if its greater than the item 2 positions back it will be inserted in front of it.
if its smaller than the item 2 position back it will be compared the item before that etc, until it find it place

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

What is merge sort?

A
  • data split into individual items
  • data is paired with adjacent data, compared then sorted.
  • data in one pair is compared with data in another pair and sorted etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly