Algorithms Flashcards

1
Q

What is the shape of a start/end box?

A

A rounded rectangle

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

What is the shape of an instruction box?

A

A rectangle

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

What is the shape of a decision box?

A

A diamond

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

Explain the bubble sort algorithm

A

Starting from the leftmost value, go through each pair of adjacent values. If they are in the incorrect order, swap them around. Otherwise leave them. Repeat this entire step until a pass is completed without making any swaps

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

In a list of N items, what is the middle item?

A

⌈(N+1)/2⌉

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

Explain the quick sort algorithm

A

Select the middle item as the pivot. For all other values, and still retaining order, if it is less than the pivot then place it to the left, else place it to the right. This creates two sub-lists, one on each side of the pivot. Repeat the process with these sub-lists, and the sub-lists formed from this, and so on, until all items have been selected as the pivot

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

Explain the binary search algorithm

A

Compare the target with the middle value. If the target is less than the middle value, discard the second half of the list (and the middle value). If it is more than the middle value, discard the first half of the list. Repeat this process until the target is either found, or there is one item left which is not the target

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

In the bin packing algorithm, how can the lower bound for the number of bins required be calculated?

A

⌈sum of heights/bin size⌉

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

Explain the first-fit bin packing algorithm

A

Each item goes in the leftmost bin that it will fit in

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

Explain the first-fit decreasing bin packing algorithm

A

The items are sorted into descending order, and then the regular first-fit algorithm is applied

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

Explain the full-bin packing algorithm

A

Observation is used to find combinations of items that will completely fill a bin. Any remaining items are packed using the first-fit algorithm

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