Give examples of real-world applications of algorithms
Give the formal definition of an algorithm
An algorithm is a sequence of steps for performing a task in a finite amount of time
What does it mean that an algorithm runs in a finite amount of time?
That when we run the algorithm with input data, it should always stop.
What is the mathematical definition of an algorithm?
A Turing Machine
What do we use data structures for in regards to computational algorithms?
We use data structures to store, access and manipulate data in computational algorithms
What is the definition of a good algorithm?
Algorithms which:
- utilise efficient data structures
- are formally correct in terms of providing the correct solution according the problem spec
- efficient in terms of speed and resources
What are our three interests in regards to algorithm analysis?
What are the two types of analysis?
What is experimental analysis of algorithms?
Analysis where we’re interested in the dependency of the running time on the size of the input.
What is the size of the input in experimental analysis?
The amount of memory you need to use in order to represent your data in the computer
What does experimental analysis involve?
Running our algorithm on input data designed for the purpose of testing it.
- This requires a good choice of sample inputs and an appropriate number of tests for statistical certainty
What does running time depend on in algorithms?
It depends on both the size and instance of input and the algorithm used as well as the software and hardware environment on which it runs.
Why might 3 different instances of inputs with the same size run through the same algorithm have varying running times?
This could be because those instances might be of varying difficulty or structural appearance.
- for example a for loop might be used in the algorithm and some input may qualify to evoke the for loop but others may not, despite being the same size of input
In experimental analysis what do we do when we have multiple instances of running time for the same input size?
We record the average running time of those instances (find the mean)
What are the potential drawbacks of experimental analysis
What are the benefits of theoretical analysis?
How do we characterise the running time of an algorithm in theoretical analysis?
We represent the algorithm’s run time with a function f(n) where n is the non negative input size
List common run time functions and their names in order of slowest to fastest
n - linear
log(n) - logarithmic
n^2 - quadratic
n*log(n), - sorting runtime
n^5 - polynomial
2^n - exponential
What type of run time is the most efficient to scale with input size
Polynomial run times are the most efficient to scale with input size
What do we need to perform formal theoretical analysis
What is pseudo code?
What are the steps for finding the minimum element of a set of numbers, stored in an array A
describe pseudocode
Describe the computational model we’re abiding by