Algorithms Flashcards

1
Q

What is an algorithm?

A

A sequence of instructions that can be followed to carry out a particular task

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

What is abstraction?

A

Removing unnecessary detail from a problem

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

What is decomposition?

A

Breaking a problem down into a number of smaller sub-problems, so that each sub problem accomplishes an identifiable task

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

How does a linear search work?

A

Works by looking at each value of the list in turn until it finds the item it is looking for

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

What are the pros and cons of a linear search?

A

It is slow, but it is easy to program and can work with an unordered
list

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

How does a binary search work?

A

Compares the middle value in the list against the value which is being attempted to be found. It then halfs the list

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

What are the pros and cons of a binary search?

A

It is fast, but can only work with ordered lists

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

How does a bubble sort work?

A

Sort takes list of unordered values and putting them into the correct order by comparing two neighbouring numbers. Each run through the bubble sort is called a pass. The bubble sort is complete when a pass finished without any
swaps being made

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

How does a merge sort work?

A

Repeatedly divides a list into two until all the elements are separated individually. Pairs of lists
are then compared, placed into order and combined. The process is then repeated until the list is recompiled as a whole

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

What are the pros and cons of the merge sort?

A

More complex to program than the bubble sort, but much faster

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