Lecture 2 Flashcards
What do you compare algorithms using run time?
The running time of an algorithm varies with the input and typically grows with the input size
An algorithm may run faster on certain data sets than on others
Best case
Worst case
Average case
What are Experimental studies?
1) Running an algorithm with inputs of varying size and composition, multiple times
2) use method System.currentTimeMills() to get accurate measure of actual run time
Limitations of Experimental studies?
It is sometimes difficult to implement the algorithm
Results may only be indicative of the running time for some inputs, but not for all possible inputs
One algorithm can perform better than the rest for some inputs. For other inputs, another algorithm could be better
The same hardware and software environments must be used
What is Asymptotic Analysis?
The technique uses a high-level description of the algorithm instead of an implementation
We evaluate the performance of an algorithm in terms of input size.
We calculate how does the time taken by an algorithm increases with the input size.
How do u estimate the running time/computation of an algorithm?
T(n) and O(n)
We refer to this resultant formulae as T(n) where n is the size of the input
If there is more than one input we might have T(n,m) (etc…) where n and m are the sizes of the inputs
We can use T(n) to compute a very important property called the Big-O O(n)
What are primitive operations?
Basic computations performed by an algorithm
Done by counting operations