SDD - Standard Algorithms Flashcards

1
Q

What are the three main differences between a Binary Search and a Linear Search?

A
  • A Binary search requires a sorted list, while a Linear search doesn’t
  • Linear checks every single value in the list, whereas Binary constantly halves the list until it finds the value
  • Binary searches work well on long lists, while Linear searches work well on short lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain what a Selection sort is…

A

A Selection sort uses two lists, the unsorted list and an empty list. The sort finds the minimum value in the list, and puts it in the first spot in the empty list, it then replaces that minimum with a dummy value, so it can’t be chosen again. It repeats this process until all the values have been sorted into the new list.

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

Explain how a Bubble sort searches…

A

A Bubble sort compares one value worth the next value and if the first value is greater they switch places. This process repeats until the maximum value has ‘bubbled’ to the end. This repeats but finishes at the second last place in the list. It continues this process until the list has been sorted.

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

How does the Insertion sort work?

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

What sorts would be most suitable for a parallel processing solution?

A

The Quick sort or the Merge sort

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

Which sort uses two lists?

A

The Selection sort

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

How does a Binary search work?

A

It continuously divides the list in half, and repeats the process on the sub list most likely to contain the search value, this repeats until the value is found or the lower index is greater than upper.

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

What does the efficiency of a sort depend on?

A

How many comparisons and swaps it will make, whether the require additional memory and whether the sort can realise if the list is already sorted half way through the sort.

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