AS Algorithms Flashcards

1
Q

How does a linear search work?

A

Checks each item one by one to see if it is the required item

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

Advantages and disadvantages of a linear search?

A
  • data set doesn’t need to be ordered
  • can be efficient for small data sets
  • inefficient for large data sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When should a linear search be used?

A

Small, unordered data sets

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

How does a binary search work?

A

Starts at the middle of the list, then repeatedly divides it in half, leaving the half with the required item in

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

What are the advantages and disadvantages of a binary search?

A
  • efficient for large data sets
  • requires the data set to be sorted first, alphabetically or numerically
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When should a binary search be used?

A

In large, ordered data sets

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

How does a bubble sort work?

A

Examines the first two items, swaps them if they are out of order then examines the next two

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

Advantages and disadvantages of a bubble sort?

A
  • very easy to implement
  • most inefficient piece of shit ever
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When should a bubble sort be used?

A

Small data sets where a small, easy to programme algorithm is required

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

How does an insertion sort work?

A

Inserts each item into its correct position in the data set one at a time

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

Advantages and disadvantages of an insertion sort?

A
  • more efficient than a bubble sort on small data sets
  • inefficient on large data sets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where should an insertion sort be used?

A

Small, ready sorted lists

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