Download Complexity - Brock Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
COSC 1P03
Analysis of Algorithms
Only Adam had no mother-in-law. That's how we
know he lived in paradise.
Data Structures and Abstraction
2.1
COSC 1P03
Analysis of Algorithms
 multiple algorithms for same problem
 time-space tradeoff
 same algorithm on various computers
 how to compare
 complexity analysis
Data Structures and Abstraction
2.2
COSC 1P03
Asymptotic Complexity




comparison independent of actual data and machine used
problem size
significant step
time complexity in terms of problem size
 e.g. g(n) = n2/2 + 5n/2 - 3
 compare functions
 approximation of g(n)
 asymptotic complexity
 dominant term
Data Structures and Abstraction
2.3
COSC 1P03
Methods
 big-O notation
 order O(…)
 order of dominant term
 definition
 desire lowest order function
 big-Ω notation
 definition
 if g(n) is O(f(n)) then f(n) is Ω(g(n))
 big-Θ notation
 definition
 if g(n) is Θ(f(n)) then g(n) is O(f(n)) and g(n) is
Ω(f(n))
 comparison
 complexity classes
 polynomial
 non-polynomial
Data Structures and Abstraction
2.4
COSC 1P03
Determining Complexity
 informal analysis
 rough count of significant step
 constant time (O(1))
 number of times independent of n
 linear code
 loops
 if number of times is a factor of n
 order is the order of the factor
 nested code
 nesting rule
 sum of the orders
 sequential code
 sequence rule
 maximum of the orders
 examples
Data Structures and Abstraction
2.5
COSC 1P03
Timing Algorithms
 determining actual run-time of algorithm
 data?
 representative set
 System.currentTimeMillis
 timing
 example – methods of different order
 results
 accuracy of results
Data Structures and Abstraction
2.6
COSC 1P03
The End
Data Structures and Abstraction
2.23
Related documents