D1 - algorithms Flashcards

0
Q

How are boxes in flow charts linked?

A

Arrowed lines.

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

What shapes are used in flow charts and what do they mean?

A

Curve circle - start/end

Rectangle - instruction

Diamond - decision

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

What is the bubble sort used for?

A

To compare adjacent items.

Sorting an unordered list into some kind of order, like numerical or alphabetical.

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

How do you carry out a bubble sort?

A

Compare adjacent values, if they are in order leave them, if not swap them.

When you get to the end of the list, repeat again for a second pass, third etc.

When no swaps are made in a pass, the list is in order.

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

How do you carry out a quick sort?

A

Choose the mid point value to be the first pivot.

Write down all the values smaller than the pivot,
followed by the pivot,
followed by the greater numbers.

Apply these steps to each sub list, and once all items have been pivots the sort Is complete.

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

What is a binary search?

A

A search in an ordered list to find out whether a particular item is in the list, if it is it locates the point.

Concentrates on the mid point of an ever halving list so is quick.

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

How do you carry out a binary search algorithm?

A
T = target
M = middle point

Select the middle item by n + 1 / 2 and round up if needed.

If T is before m then the second half of the list can be discarded.
Vice versa.

Repeat until T is found or until you result in one value which is not T.

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

How do you determine the lower noun of bin packing?

A

Sum up all the heights and divide by the bin size.

Then round up your answer to determine the lower bound/minimum number of bins needed.

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

How do you carry out the first fit algorithm?

Also first fit decreasing algorithm

A

Do not change the given order.

Place each bin in the first available bin it can take, starting from bin 1 each time.

Quick.
Not very good solution.

Reorder into descending order and apply first fit.

Quick, easy and fairly good solution.
May not get optimal solution.

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

Describe how to carry oh the full bin packing algorithm.

A

Use observation to find combinations of items that will fill a bin.

Any remaining items are packed by first fit.

Good solution.
Awkward with plentiful numbers/awkward full value or numbers.

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