Sorting Algorithms Flashcards

1
Q

What are the three steps to the Bubble Sort Algorithm?

A
  1. If there is only one number, stop
  2. Make one pass, swapping as necessary
  3. If no swaps have occurred, stop, otherwise, restart
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the first three passes of the Shuttle Sort Algorithm like?

A

Pass 1. Compare the 1st and 2nd numbers. Swap if necessary
Pass 2. Compare the 2nd and 3rd numbers. Swap if necessary. If a swap has occurred, compare the 1st and 2nd numbers again. Swap if necessary
Pass 3. Compare the 3rd and 4th numbers. Swap if necessary. If a swap has occurred, compare the 2nd and 3rd numbers again. Swap if necessary. If a swap has occurred, compare the 1st and 2nd numbers again. Swap if necessary.
etc.

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

In what ways might the shuttle sort be more efficient than the bubble sort? In what ways might in not?

A

Shuttle sort can successfully sort a set of numbers with fewer comparisons than bubble sort (not always)
Both sorting methods must use the exact same number of swaps, as both have to sort the same number set into the same order.

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

How does the first fit algorithm work?

A

Each object is placed into the first available space in which it will fit

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

How does the first fit decreasing algorithm work?

A

Sort numbers into descending order, then use the first fit algorithm

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