Académique Documents
Professionnel Documents
Culture Documents
Lecture
1:
Introduction
Rossella Lau
Algorithms:
Rossella Lau
Rossella Lau
A structure
A structure
structures
Rossella Lau
Storage Container
For storing multiple occurrences of a structure
Contiguous
structures:
Linked
Combination
Rossella Lau
v e c to r v (w ith 5 e le m e n ts )
7
4
9
3
1
v .re s iz e (8 ); (g ro w to 8 e le m e n ts )
7
4
9
3
1
0
0
v .re s iz e (3 ); (s h rin k to 3 e le m e n ts )
7
4
9
//
fro n t
re a r
n e w Ite m
Rossella Lau
Operations
Rossella Lau
ADT
An abstract model of a data structure together
with the operations (can be treated as a form of
algorithms) processed on the data structure.
In
Rossella Lau
Algorithms
A simplified view: clear process steps
E.g.,
A vector
class
int
int
int
};
Vector{
*array;
size;
capacity;
reSize(int newSize) {
Define a new array with newSize
if newSize >= capacity
Copy the contents from *array
to the new array
Assign newSize to capacity
Make the new array as *array
Throw away the old array
}
Rossella Lau
Rossella Lau
Rossella Lau
Can
How
Rossella Lau
Algorithm analysis
To understand how good or how bad an algorithm is
Theoretically
evaluate an algorithm
Execution time
Storage efficiency
Experimentally
evaluate an algorithm
Rossella Lau
Rossella Lau
Additional to C++
Extend
Rossella Lau
Summary
This
Organization
Algorithms
There
Rossella Lau
Reference
Ford:
C++
1.2-3, 3.2
Complete Reference
-- END --
Rossella Lau