Performance Analysis
Performance Analysis
BASIC CONCEPT
CHAPTER 1 1
How to create programs
Requirements
Analysis: bottom-up vs. top-down
Design: data objects and operations
Refinement and Coding
Verification
– Program Proving
– Testing
– Debugging
CHAPTER 1 2
Algorithm
Definition
An algorithm is a finite set of instructions that accomplishes a particular task.
Criteria
– input
– output
– definiteness: clear and unambiguous
– finiteness: terminate after a finite number of steps
– effectiveness: instruction is basic enough to be carried out
CHAPTER 1 3
Data Type
Data Type
A data type is a collection of objects and a set of operations that act on those
objects.
Abstract Data Type
An abstract data type(ADT) is a data type that is organized in such a way that the
specification of the objects and the operations on the objects is separated from the
representation of the objects and the implementation of the operations.
CHAPTER 1 4
Specification vs. Implementation
Operation specification
– function name
– the types of arguments
– the type of the results
Implementation independent
CHAPTER 1 5
*Structure 1.1:Abstract data type Natural_Number (p.17)
structure Natural_Number is
objects: an ordered subrange of the integers starting at zero and ending
CHAPTER 1 7
Fixed Space Requirements (C)
Independent of the characteristics of the inputs and outputs
– instruction space
– space for simple variables, fixed-size structured variable, constants
CHAPTER 1 8
*Program 1.9: Simple arithmetic function (p.19)
float abc(float a, float b, float c)
{
return a + b + b * c + (a + b - c) / (a + b) + 4.00;
}
Sabc(I) = 0
Assumptions:
*Figure 1.1: Space needed for one recursive call of Program 1.11 (p.21)
CHAPTER 1 10
Time Complexity
T(P)=C+TP(I)
CHAPTER 1 11
Time Complexity
Example
– abc = a + b + b * c + (a + b - c) / (a + b) + 4.0
– abc = a + b + c
CHAPTER 1 13
Tabular Method
*Figure 1.2: Step count table for Program 1.10 (p.26)
Iterative function to sum a list of numbers
steps/execution
Statement s/e Frequency Total steps
float sum(float list[ ], int n) 0 0 0
{ 0 0 0
float tempsum = 0; 1 1 1
int i; 0 0 0
for(i=0; i <n; i++) 1 n+1 n+1
tempsum += list[i]; 1 n n
return tempsum; 1 1 1
} 0 0 0
Total 2n+3
CHAPTER 1 14
Recursive Function to sum of a list of numbers
*Figure 1.3: Step count table for recursive summing function (p.27)
CHAPTER 1 15
Matrix Addition
*Figure 1.4: Step count table for matrix addition (p.27)
CHAPTER 1 16