Algorithm assessment
- Is the algorithm running in constant time?
- Runs the same amount of time no matter when 'n' is
- O(1)
- No loops or constant time loops
- No loops or constant time loops
- Runs the same amount of time no matter when 'n' is
- Linear time
- Does the problem run exactly proportional to the size of 'n'?
- Dominant single loop dependant linearly on n
- Does the problem run exactly proportional to the size of 'n'?
- Logarithmic
- The algorithm divides the size of the problem by a constant
- Runs in O(log n)
- Dominant single lop is a divide by 2 on each iteration
- Dominant single lop is a divide by 2 on each iteration
Assertions
- Boolean expressions or predicates that evaluate to true or false
- In a program they express constraints on the state that must be true at that point
- Associate with
- Individual program statements
- Functions
- Classes
- Individual program statements
- Specify clearly, precisely and succinctly
- What is expected and guaranteed by each component
- Class function and statement
- Class function and statement
- The essence of documentation
- Essential for debugging
- Aids in fault tolerance
- Result
- Result of a query but only in ensure assertions
- Result of a query but only in ensure assertions
- Current
- @ Current object
- @ Current object
- Void
- Not attached
- Not attached
- Name
- Value of the variable name before a routine starts
- Value of the variable name before a routine starts
- Name'
- Value of the name after a routine terminates
- Alternate name 'old name' instead of Name'
- Value of the name after a routine terminates
- **study textual notation**
- From online notes, cannot type all this
- From online notes, cannot type all this
No comments:
Post a Comment