2.1 Sort Algorithms Flashcards
1
Q
Sort Algorithm
A
A sort algorithm is a set of instructions to arrange a dataset into a particular order.
2
Q
Efficient Sorting
A
An efficient sort algorithm is one which can sort a dataset in a short time.
3
Q
What are the three examples of sorting method
A
- Bubble sort
- Insertion sort
- Merge sort
4
Q
Bubble sort
A
- Compare the first two items of the dataset:
- Swap these items if they aren’t in the right order.
- Continue for the rest of the cards in the deck.
- Repeat the whole process, until a pass with no swaps happens.
5
Q
Pros and Cons of bubble sort
A
Easy to implement
Does not use much memory
Poor efficiency
6
Q
Insertion sort
A
Compare 2nd card with previous card
then 4rd card with 2nd card
repeat this for the whole list
7
Q
Pros and cons of insertion sort
A
Easy to implement
Little memory used
Not very efficient
8
Q
Merge sort
A
- Split the lists into lists of size one.
- Merge each pair of sub lists by comparing the first value of each list and putting the smaller value into the new list first.
- Continue merging until there is only one list.
9
Q
Pros and Cons of Merge sorts
A
Very efficient algorithm
Can be slower for small lists
Needs additional memory