Lecture 1
Lecture 1
Introduction to Data
Structure and Algorithm
Outline
Data Structures
Abstract Data Types
Abstraction
Algorithms
Properties of an algorithm
Introduction to Data Structures and Algorithms Analysis
Introduction to Data Structures and Algorithms Analysis
A program
A set of instruction which is written in
order
to solve a problem.
5
Therefore, a program is Data structures + Algorithm.
Introduction to Data Structures
The first step to solve the problem is
obtaining ones own abstract view, or
model, of the problem.
Abstraction
11
Data Structure
12
Data Structure
Static Vs Dynamic DS
Type: Set of values that can be stored + set of operations that can be performed.
Inputs Algorithm
Outputs
19
Algorithm
What is the purpose of algorithms in programs?
Take values as input. Example: cin>>age;
Produce
outputs:
Example: Display student’s information 20
Algorithm
The quality of a data structure is related to its
ability to successfully model the characteristics
of the world (problem).
21
Algorithm
Generally
speaking, correct data structures lead
to simple and efficient algorithms.
22
Properties of Algorithms
Finiteness:
Each step must be clearly defined, having
one and only one interpretation.
24
Sequential:
Each step must have a uniquely defined
preceding and succeeding step.
25
Feasibility:
2) int x,y;
cin>>x;
y=x*x*x;
cout<<y;
29
E x a mp le:
30
Input/output:
Precision:
The result should always be the same if the
algorithm is given identical input.
31
Simplicity:
Levels of abstraction:
Used to organize the ideas expressed in
algorithms.
Used to hide the details of a given activity and
refer to just a name for those details.
The simple (detailed) instructions are hidden
inside modules.
32
Well-designed algorithms are organized in terms
Next Class