Decision C1 - Algorithms Flashcards

1
Q

Define algorithm

A

A finite sequence of step-by-step instructions carried out to solve a problem

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

What does an oval mean in a flow chart?

A

Start / End

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

What does a rectangle mean in a flow chart?

A

Instruction

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

What does a diamond mean in a flow chart?

A

Decision

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

What type of sorting algorithms are there for unordered lists?

A

Bubble sort and quick sort

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

Describe the steps to carry out a bubble sort

A

Compare adjacent items in a list

If they’re in order, leave them

If they aren’t in order, swap them

The list is ordered when a pass in completed without any swaps

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

Describe the steps to carry out a quick sort

A

Select a pivot (the middle) then split the items into 2 sub lists

One sub list contains items less than the pivot

The other sub list contains items greater than the pivot

Select further pivots from within each sub list and repeat the process

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

What are all of the bin packing methods and how do they work?

A

First-fit:
Take items in order given
Place in first bin available that can take it
Start from bin 1 each time

First-fit decreasing:
Sort into descending order
Take items in order given
Place in first bin available that can take it
Start from bin 1 each time

Full-bin packing:
Use observation to find combinations of items that will fill a bin. Pack these items first
Take items in order given
Place in first bin available that can take it
Start from bin 1 each time

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

How do you calculate the lower bound of a bin?

A

Sum up all the item sizes and divide by the bin size. Then round up

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

What are the advantages and disadvantages of the first-fit algorithm?

A

+: Quick to implement
-: Not likely to lead to a good solution

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

What are the advantages and disadvantages of the first-fit decreasing algorithm?

A

+: Usually a good solution
+: Easy to implement
-: May not get an optimal solution

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

What are the advantages and disadvantages of the full-bin algorithm?

A

+: Usually a good solution
-: Difficult to do, especially when the numbers are plentiful and awkward

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

if an algorithm has an order f(n), then increasing the size of the problem from n to m will increase the run time of the algorithm by a factor of approximately…

A

f(m) / f(n)

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

How do you calculate the run time of an algorithm?

A

Original run time * Scale Factor^Order of the algorithm = Run time

o.e

OT * k^x = NT

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