Algorithms And Flow Charts Flashcards

1
Q

How to use an algorithm

A

Make a table with a column for each step

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

When to move on to the next row of a table?

A

When you have to move left in the table or fill a square which already has a number

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

Flow charts start/end shape

A

Oval

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

Flow charts instruction shape

A

Rectangle

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

Flow charts decision shape

A

Diamond

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

Bubble Sort Process

A

Check whether it is ascending or descending
Start at the left value and compare with the one to the right of it
Draw a curvy line between and point the end if you swap them
Use whichever value ended up on the right side of those and compare with the one to the right
When you finish this once the rightmost value is in the right place
Write the amount of comparisons and swaps each time
Repeat not checking the rightmost value
Stop when you make 1 check or no swaps

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

Bubble sort, how does the amount of comparisons change each time

A

It decreases by 1

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

Bubble sort, what is the most amount of comparisons needed for a list of 10

A

45

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

Quick Sort Process

A

Check if ascending or descending
Choose the middle or middle-right value to be the pivot and circle it
Make a sub-list of bigger and smaller values on each side of the pivot (not ordered) which side depends on ascending or descending
Draw a downwards line each side of the pivot
Simultaneously repeat for each sub-list and keep going until all values have been pivots or are surrounded by lines

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

Which sorting method is quicker

A

Quick Sort

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

How to find the lower bound of the amount of bins required

A

Sum of all the sizes
________________
Bin size

Round up to next whole number

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

First-fit bin packing algorithm

A

Take the items in the order given
Place each in the first available bin

+ 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
13
Q

First-fit decreasing algorithm

A

Sort the items into descending order
Apply the first-fit algorithm

+ easy to implement, fairly good solution
- may not get an optimal solution

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

Full-fit bin packing algorithm

A

Use observation to find combinations of items which will fill a bin and pack these first.
Use first-fit for any remaining items

+ Usually get a good solution
- Difficult to do, especially for lots of/awkward numbers

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

Bin-packing algorithm

A

Bin | Items in Bin | Space in Bin

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

Order of an algorithm

A

Can also be known as the complexity of an algorithm

How changes in size of the problem affect the approximate run time of the algorithm

17
Q

If the size is increased by k then

A

Linear: the time increases by a factor of k
Quadratic: the time increases by a factor of k^2
Cubic: the time increases by a factor of k^3

18
Q

How to go from the change in time to the change in size

A

If k is the change in k

Linear: the size increases by k
Quadratic: the size increases by root k
Cubic: the size increases by the cube root of k

19
Q

Why does the first-fit bin packing algorithm have quadratic order?

A

Because for n items, at most n-1 bins need to be checked

n(n-1) which is a quadratic

20
Q

Why does bubble sort have quadratic order?

A

Pass 1 has (n-1) comparisons and pass 2 (n-2) and so on
(n-1) + (n-2) + … + 2 + 1
Arithmetic series n/2(n+1)