Modelling With Algorithms Flashcards
Key points of algorithms
- set of instructions
- finite number of steps
- must work for any input
- must have an end
How can algorithms be written?
As text
As a flowchart
As pseudocode
What are some key points for algorithms using pseudocode?
How do we compare how well algorithms work?
- the efficiency of an algorithm measures ‘run time’ and is usually proportional to the number of calculations that need to be carried out
- the size of the problem is a measure of complexity so in the case of sorting algorithms it’s likely to be the number of elements in the list
- the complexity of an algorithm measures efficiency as a function of the size of the problem. Complexity is indicated by the ORDER
What are the different methods for bin packing?
- Full bin algorithm where we look for combinations that make full bins
- First fit algorithm, where we put boxes into bins first fit in the order that they are already in starting from the first bin every time
- first fit descending
What are some qualities of first fit algorithm?
- heuristic (solves the problem but doesn’t find an optimal solution)
- easy to carry out or program
- can be inefficient
- systemic approach
What are some qualities of the bin packing algorithm?
- can be used in real life contexts (cutting a length of wood, parking vehicles in ferry lanes)
- not guaranteed to give optimal solution
- first fit decreasing is often more efficient than first fit
- must remember to check from first bin onwards with each new item
When are sorting algorithms used?
- when we want to sort a list of numbers into ascending order or words into alphabetical order
- we may do this when we require a sorted list E.g to use first fit decreasing algorithm
What is the quick sort algorithm?
Step 1: Select the pivot element (first element) from the list
Step 2: Write down all of the numbers that are smaller than the pivot in a sub-list to the left of the pivot, keeping the numbers in their original order. Write down all of the numbers that are larger than the pivot in a sub-list to the right of the pivot, keeping the numbers in their original order.
Step 3: Apply steps 1 and 2 to each separate sub-list until each sub-list contains only one number.
Look at Goodnotes for formulae and diagrams
:)
What are the dots and lines called in a graph?
Dots: nodes or vertices
Lines: arcs or edges
What is a graph?
A series of nodes/vertices connected by edges/arcs
How do you find the degree/order of a vertex?
Count how many ends of edges there are at the vertex
How do you know if a graph is impossible to draw?
Total order is odd
What is a loop
An edge that starts and ends at the same vertex