Sorting/Searching Algorithms Flashcards

(5 cards)

1
Q

How does Bubble Sort work?

A
  • Comparing each x and x+1 index
  • Brings the largest number to the right every pass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does Optimized Bubble Sort work?

A
  • Uses a swap flag to stop the method if no swaps are detected in a pass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does Selection Sort work?

A
  • First is chosen as the minimum
  • x and x+1 are compared until the smallest is found
  • minimum is moved to left
  • second is chosen… third… fourth… etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does Insertion Sort work?

A
  • The first index is part of the array that is “already sorted”
  • The next index is used and put in the part of the array that is already sorted
  • A key is used
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Binary Search work?

A
  • Splits an array into halves until the target is found
  • Uses a high, low, and mid pointer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly