Introduction
Introduction
A program
A set of instruction which is written in
order
to solve a problem.
Therefore,
a program is Data structures
plus Algorithm.
4
Introduction to Data Structures
Data structures are used to model the world or
part of the world. How?
1. The value held by a data structure represents some
specific characteristic of the world.
2. The characteristic being modeled restricts the possible
values held by a data structure and the operations to
be performed on the data structure
The first step to solve the problem is
obtaining ones own abstract view, or
model, of the problem.
This process of modeling is called
abstraction.
Introduction....(continued)
Abstraction
Type: Set of values that can be stored + set of operations that can be performed.
Inputs Algorithm
Outputs
14
Algorithm
An algorithm transforms data structures
from one state to another state.
What is the purpose of algorithms in programs?
Take values as input. Example: cin>>age;
Change the values held by data structures. Example:
age=age+1;
Change the organization of the data structure:
Example:
Sort students by name
Produce outputs:
16
Algorithm
17
Properties of Algorithms
Finiteness:
Each step must be clearly defined, having
one and only one interpretation.
19
Sequential:
Each step must have a uniquely defined
preceding and succeeding step.
20
Feasibility:
2) int x,y;
cin>>x;
y=x*x;
cout<<y;
24
E x a mp le:
25
Input/output:
26
Next Class
Chapter Two
Algorithm Analysis Concepts
Complexity Analysis
Formal Approach to Analysis
Asymptotic Analysis
The Big-Oh Notation
Big-Omega Notation
Theta Notation