algorithms analysis Flashcards
what does correctness mean in algorithm analysis
an algorithm outputs the expected correct value
what is time efficiency
how fast and alorithm is excuted to get the result. the running time depends on the number of instructions to excute
what is space (memory) efficency
how much memory does the algorithm need during excution
what are the 3 things algorithm analysis look at
- correctness
- time efficency
- space ( memory) efficency
what are some things that affect run time
- hardware
- software
- typically grows with the input size
what are the analysis types
- worst case
- best case
- average case
what are the limitations to runnign experiments for run time
- it is nessary to implement the algorithm which could be hard
- in order to compare two algorithms the same hardware and eviroments must be used
- results may not be indicative of the running time on other inputs not included in the experiment
what is theoretical analysis
- uses pseudocode instead of implementation
- characterizes running time as a function of the input size n
- take into account all possible inputs
- allow us to evaluate the speed of an algorithm independent of teh hardware/software enviroment
how do you determinte the theoritical analysis of running time
determine the number of primitive operations ( basic operations) as a function of the input size
what is a primative operation
- basic computatiions performed by algorithm
- assume to take a constant execution time
- largely independent from the programming language
what are some examples of primative operations
ex
- assigning value to a variable
- evaluating an arithmetic expression or boolean expression
- accessing a single element of an array by index
- calling a method
- returning from a method
if wose case is (3n-1) and 2n is the best case what id the what is the worst case time of it
a(2n) <= T(n) <= (3n-1)
a- is fastest primative operation
b is slowest primative operation
does changing in hardware/ssoftware enviroment affect the growth rate of running time?
- this affects T(n) by a constant factor
- does not alter the growth rate of T(n)
why does growth rate matter
- can distinguish efficient vs inefficient algorthims
- many large scale instances can be solved more easily
- many real world problems have large sizes
- small diffreneces on small input sizes
what does not affect growth rate?
- constant factord
- lower order terms