1/10
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the algorithm of a bubble sort?
1) Look at the first two items in the list.
2) If they’re in the right order, don’t do anything. If they aren’t, swap them.
3) Move onto the next pair of items, as repeat step 2.
4) Repeat step 3 until you get to the end of the list - called one pass. The last item will be in the correct place, so don’t include it in the next pass.
5) Repeat steps 1-4 until there are no swaps in a pass.
What type of algorithm is a bubble sort?
Simple
Is a bubble sort efficient?
Not to sort a list, but to check if a list is in order.
Does a bubble sort use a lot of memory?
No
What is the algorithm for a merge sort?
1) Split the list in half, the second sub-list should start at the middle item.
2) Keep repeating step 1 on each sub-list until all lists only contain one item.
3) Merge pairs of sub-lists and each time you merge sub-lists, sort the items into the right order.
4) Repeat step 3 until you’ve merged all the sub-lists together.
What is a pro of a merge sort?
More efficient
How quickly does a merge sort sort small lists?
Slower compared to other algorithms.
How much memory does a merge sort use compared to the other sorting algorithms?
More memory.
What is the algorithm for a insertion sort?
1) Look at the second item in a list.
2) Compare it to all items before it and insert the number into the right place.
3) Repeat step 2 until the last number in the list has been sorted into the correct place.
What size list does an insertion sort cope best with?
Small.
How quick is an insertion sort?
Very quick.