Algorithms Flashcards

1
Q

What is meant by decomposition?

A

Breaking a complex problem down into smaller problems and solving them individually.

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

What is meant by abstraction?

A

Separating the important parts out from the problem (ignoring unnecessary details)

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

Why is using algorithmic thinking useful when solving a problem?

A

If the steps you take to solve a problem follow an algorithm then they can be reused and adapted to solve similar problems in the future.

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

What is pseudocode?

A

A neutral, made-up coding language made to roughly write out algorithms to be converted to another language,

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

Give three features of well-written pseudocode.

A

Readable
Easy to interpret
Not too vague

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

What are the benefits of writing algorithms in psuedocode rather than a programming language?

A

It is quick to write and can be easily converted to another programming language.

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

What are the four steps of the binary search algorithm?

A

Find the middle item in the ordered list.
If this is the item searched for, then stop (it is found).
If not, compare the searched item with the middle item - if it comes before the middle item, discard the second half of the list (or vice versa)
Repeat steps 1-3 until the item is found.

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

What are the four main steps of a linear search algorithm?

A

Look at the first item in the unordered list.
If this is the item searched for, then stop (it is found).
If not, check the second item in the list. If this is the item searched for, then stop (it is found).
Repeat steps 1-3 until the item is found.

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

What are the benefits and drawbacks of using a linear search over a binary search?

A

Benefits - can be used on any type of list, similar run time when used in a small (ordered) list
Drawbacks - slower when used on a large (ordered) list

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

What are the five steps of the bubble sort algorithm?

A

Check the first 2 items in the list.
If they’re in the right order, leave them alone. If they’re wrong, swap them.
Move onto the next pair of items (2nd & 3rd) and repeat step 2.
Repeat step 2 until you reach the end of the list. (one pass)
Repeat steps 1-4 until there are no swaps left to make.

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

What are the four steps of the merge sort algorithm?

A

Split list in half to make 2 sub-lists
Repeat step 1 until all the sublists contain 1 item
Merge pairs of sublists so when they are combined, they are sorted
Repeat step 3 until all the sublists are merged and in order

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

What are the strengths and weaknesses of bubble sort?

A

Strengths - simple algorithm, doesn’t use much memory

Weaknesses - slow (for large lists), inefficient

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

What are the strengths and weaknesses of merge sort?

A

Strengths - generally more fast and efficient, consistent running time
Weaknesses - uses more memory than bubble sort

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