Introduction To Data Structures and Algorithm Analysis: Education For A Fast Changing World
Introduction To Data Structures and Algorithm Analysis: Education For A Fast Changing World
Computer Engineering is
about
Programming Life
Cycle Activities
Problem analysis
Requirements definition
Implementation of design
code it
Software Engineering
A disciplined approach to the
design, production, and
maintenance of computer programs
that are developed on time and
within cost estimates,
using tools that help to manage the
size and complexity of the resulting
software products.
Toolboxes:
Hardware.
Software
Ideaware (focus of the course!):
the shared body of knowledge
that programmers have collected
over time, including algorithms,
data structures, programming
methodologies, tools
An Algorithm Is . . .
A logical sequence of discrete
steps that describes a complete
solution to a given problem
computable in a finite amount of
time.
Goals of Quality
Software
It works.
It can be read and understood.
It can be modified.
It is completed on time and within
budget.
Specification:
Understanding the
Problem
Detailed Program Specification
Tells what the program must
do, but not how it does it.
Is written documentation
about the program.
Writing Detailed
Specifications
Detailed Program Specification
Includes:
Inputs
Outputs
Processing requirements
Assumptions
Abstraction
A model of a complex system
that includes only the details
essential to the perspective of
the viewer of the system.
Information Hiding
Hiding the details of a function
or data structure with the goal
of controlling access to the
details of a module or structure.
PURPOSE: To prevent high-level
designs from depending on low-level
design details that may be changed.
Two Approaches to
Building Manageable
Modules
OBJECT-ORIENTED
FUNCTIONAL
DECOMPOSITI
ON
DESIGN
Identifies various
objects composed of
data and operations,
that can be used
together to solve
the problem.
Functional Design
Modules
Main
Prepare
File for
Reading
Get Data
Print Data
Find
Weighted
Average
Print
Weighted
Average
Print Heading
Object-Oriented Design
A technique for developing a program in which the
solution is expressed in terms of objects -- selfcontained entities composed of data and
operations on that data.
cin
<<
>>
get
.
.
.
cout
Private data
setf
.
.
.
Private data
ignore
Verification of
Software
Correctness
Testing
Debugging
Program verification
Program Verification
Program Verification is the process of
determining the degree to which a
software product fulfills its specifications.
SPECIFICATIONS
Inputs
Outputs
PROGRAM
Processing
Requirements
Assumptions
Program Testing
Testing is the process of
executing a program with
various data sets designed to
discover errors.
DATA SET 1
DATA SET 2
DATA SET 3
DATA SET 4
...
Origin of Bugs
Various Types of Errors:
Design errors occur when specifications
are wrong
Compile errors occur when syntax is wrong
Run-time errors result from incorrect
assumptions, incomplete understanding of
the programming language, or
unanticipated user errors.
Robustness
Robustness is the ability of a program
to recover following an error; the
ability of a program to continue to
operate within its environment.
An Assertion
Is a logical proposition that is either
true or false (not necessarily in C++
code).
EXAMPLES
studentCount is greater than 0
sum is assigned && count > 0
response has value y or n
partNumber == 5467
Preconditions and
Postconditions
The precondition is an assertion
describing what a function requires to
be true before beginning execution.
The postcondition describes what
must be true at the moment the
function finishes execution.
The caller is responsible for ensuring
the precondition, and the function
FOR EXAMPLE . . .
code must ensure the postcondition.
Program Testing
Unit Testing: testing a module or
function by itself
Data Coverage: testing all possible
input values (Black Box Testing)
Code Coverage: testing program
paths (Clear/White Box Testing)
Test Plans
Planning for Debugging
Integration Testing
Integration Testing
Is performed to integrate program
modules that have already been
independently unit tested.
Main
Prepare
File for
Reading
Get Data
Print Data
Find
Weighted
Average
Print
Weighted
Average
Print Heading
Integration Testing
Approaches
TOPDOWN
Ensures correct overall
design logic.
USES: placeholder
module stubs to test
the order of calls.
BOTTOM-UP
Ensures individual modules
work together correctly,
beginning with the
lowest level.
USES: a test driver to call
the functions being tested.
Life-Cycle Verification
Activities:
Analysis
Design
Code
Test
Delivery
Maintenance
Programs and
Programming
The computer only knows what is told
Control Structures
Control Structure is the logic
behind the program.
Sequence: Input, Storage,
Arithmetic and output
Decision: comparing two values an
selecting one.
Repetition: Going through loop
Programming
Language
is a set of restricted vocabulary and
structured syntax that a computer can
understand
is a language used to write computer
programs, which involve a computer
performing some kind of computation or
algorithm and possibly control external
devices such as printers, robots, and so
on.
Programming
Language
Programming
Language
Graphical Representation
Total = 0
A=1
B=2
Total = A + B
Translation
Program
0110101011
0100101
01011010
01010010
Linker
The object code for your C++ program must be
combined with the object code for routines (such
as input and output routines) that your program
uses. This process of combining object code is
called linking and is done by a program called a
linker. For simple programs, linking may be done
for you automatically.
Programming
Language
What is an Algorithm?
A sequence of unambiguous
instructions for solving a problem, i.e.,
for obtaining a required output for any
legitimate input in a finite amount of
time.
Algorithms are used for calculation,
data processing
list of well-defined instructions for
completing a task
What is an Algorithm?
An algorithm is a well-developed,
organized approach to solving a
complex problem.
Computer Scientists ask
themselves four critical
questions when they evaluate
algorithms
Algorithm Questions
Does the algorithm solve the
stated problem?
Is the algorithm well-defined?
Does the algorithm produce an
output?
Does the algorithm end in a
reasonable length of time?
Developing an
Algorithm
1. Identify the Inputs
2. Identify the Processes
3. Identify the Outputs
4. Develop a HIPO Chart
5. Identify modules
2. Identify the
Processes
5. Identify Relevant
Modules
Importance of
Algorithm
Using an algorithm in planning for a solution
helps in several ways:
First, it allows the individual to see things in a
wider perspective thereby weeding through
all other possible solutions to pick the best
one. Since in coming up with an algorithm the
individual is not stuck with using a specific
language, the person may use whatever tool
(i.e. flowchart, layman's term, etc.) that is
comfortable; putting emphasis on how to go
about solving an issue.
Importance of
Algorithm
Importance of
Algorithm
Properties of Algorithm
1) Finiteness: - an algorithm terminates after
a finite numbers of steps.
2) Definiteness: - each step in algorithm is
unambiguous. This means that the action
specified by the step cannot be interpreted
(explain the meaning of) in multiple ways
& can be performed without any confusion.
3) Input:- an algorithm accepts zero or more
inputs
Properties of Algorithm
4) Output: it produces at least one
output.
5) Effectiveness:- it consists of basic
instructions that are realizable. This
means that the instructions can be
performed by using the given inputs
in a finite amount of time.