Decision 1&2 definitions Flashcards
What is an algorithm?
A finite sequence of step by step instructions carried our to solve a problem
What do the different boxes in flow charts represent?
Oval : Start/ end
Rectangle: Instruction
Diamond: Decision
What is a trace table?
A table the keeps track of the step at which you are at and the value of all variables at that step as the algorithm is run
What is a bubble sort?
A type of sorting algorithm where adjecent items in alist are swapped if they are not in order until the list is sorted.
What is a working list?
A list where all comparisons are made
Whats is a sorted list?
A list containg all items that are in their final position
What is a quick sort?
A sorting algorithm where:
* You select a pivot then split the items into two sublists
* One sublist contains items less than the pivot
* The other sublist contains items greater than the pivot
* You then select further pivots from within each sublist and repeat the process
What are the three bin-packing algorithms?
First-fit
First-fit decreasing
Full-bin
How does the first-fit algorithm work?
Works by considering items in the order they are given.
* Take the items in the given order
* Place each item in the first available bin that can take it.Start from bin 1 each time
What is the lower bound for the number of bins needed?
An optimal solution (uses the least amount of bins) that cannot be improved upon.
How does the first-fit decreasing algorithm work?
Requires the item to be in descending order before applying the algorithm.
* Sort items in descending order
* Apply firt-fit algorithm to reordered list
How does the full-bin packing algoritm work?
Uses inspection to select items that will combine to fill bins.Remaining items are packed using first-fit algorithm.
* Uses observation to find combinations of items that will fill a bin.Pack these items firts.
* Any remaining items are packed using the first-fit algorithm.
Advatages and disadvatages of first-fit
Adv: Quick to implement
Dis: It is not likely to lead to a good solution
Advatages and disadvatages of first-fit decreasing
Adv: You usually get a fairly good solution. Easy to implement.
Dis: You may not get optimal solution
Advatages and disadvatages of full-bin
Adv: Usually get good solution
Dis: Difficult to do, especially when the numbers are plentiful and awkward