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.

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

Efficient Sorting

A

An efficient sort algorithm is one which can sort a dataset in a short time.

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

What are the three examples of sorting method

A
  • Bubble sort
  • Insertion sort
  • Merge sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Pros and Cons of bubble sort

A

Easy to implement
Does not use much memory

Poor efficiency

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

Insertion sort

A

Compare 2nd card with previous card
then 4rd card with 2nd card
repeat this for the whole list

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

Pros and cons of insertion sort

A

Easy to implement
Little memory used

Not very efficient

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Pros and Cons of Merge sorts

A

Very efficient algorithm

Can be slower for small lists
Needs additional memory

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