Sorting Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Different types of sort algorithms

A

Bubble Sort
Merge Sort
Insertion Sort

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

Bubble Sort

A

Used to order a list

  1. Look at first 2 terms
  2. If ordered move on to next pair
  3. If not ordered, swap them
  4. Repeat until you get through all the terms once = pass
  5. Repeat until there are no swaps in a pass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Pros of Bubble Sort

A

Simple Algorithm
Efficient way of checking if a list is in order
Little memory used

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

Cons of Bubble Sort

A

Inefficient to sort a list
Doesn;t work well with large lists

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

Merge Sort

A
  1. Split list in half (creates 2 sublists)
  2. Repeat till all sublists contain only 1 term
  3. Merge 2 sub-lists together and sort into right order
  4. Repeat Step 3 till all the sub-lists have been merged together
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Pros of Merge Sort

A

More efficient than bubble sort and insertion sort for large lists

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

Cons of Merge Sort

A

Even if the terms are already sorted, it goes through the whole process
Uses lots of memory

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

Insertion Sort

A
  1. Look at 2nd term in list
  2. Compare it to all terms before it and insert number in right place
  3. Repeat step 2 for all terms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Pros of insertion sort

A

Easily coded
Good with small lists
Quick

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

Cons of insertion sort

A

doesn’t cope well with large lists

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