0% found this document useful (0 votes)
53 views53 pages

Introduction To Data Structures and Algorithm Analysis: Education For A Fast Changing World

The document discusses key concepts in programming including the software development life cycle, algorithms, data structures, abstraction, information hiding, functional and object-oriented design, testing, debugging, and verification. It also covers programming languages, control structures, and the translation process from high-level languages to binary machine code.

Uploaded by

topherski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views53 pages

Introduction To Data Structures and Algorithm Analysis: Education For A Fast Changing World

The document discusses key concepts in programming including the software development life cycle, algorithms, data structures, abstraction, information hiding, functional and object-oriented design, testing, debugging, and verification. It also covers programming languages, control structures, and the translation process from high-level languages to binary machine code.

Uploaded by

topherski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 53

Introduction to Data

Structures and Algorithm


Analysis

EDUCATION FOR A FAST CHANGIN

Computer Engineering is
about

EDUCATION FOR A FAST CHANGIN

Programming Life
Cycle Activities

Problem analysis

understand the problem

Requirements definition

specify what program will do

High- and low-level design

how it meets requirements

Implementation of design

code it

Testing and verification detect errors, show correct


Delivery turn over to customer
Operation

use the program

Maintenance change the program

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Goals of Quality
Software
It works.
It can be read and understood.
It can be modified.
It is completed on time and within
budget.

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Writing Detailed
Specifications
Detailed Program Specification
Includes:
Inputs
Outputs
Processing requirements
Assumptions

EDUCATION FOR A FAST CHANGIN

Abstraction
A model of a complex system
that includes only the details
essential to the perspective of
the viewer of the system.

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Two Approaches to
Building Manageable
Modules
OBJECT-ORIENTED

FUNCTIONAL
DECOMPOSITI
ON

Divides the problem


into more easily handled
subtasks, until the
functional modules
(subproblems) can
be coded.

FOCUS ON: processes

DESIGN
Identifies various
objects composed of
data and operations,
that can be used
together to solve
the problem.

FOCUS ON: data objects

EDUCATION FOR A FAST CHANGIN

Functional Design
Modules
Main

Prepare
File for
Reading

Get Data

Print Data

Find
Weighted
Average

Print
Weighted
Average

Print Heading

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

More about OOD

Languages supporting OOD include: C++, Java,


Smalltalk, Eiffel, and Object-Pascal, C,

A class is a programmer-defined data type and objects


are variables of that type.

In C++, cin is an object of a data type (class) named


istream, and cout is an object of a class ostream.
Header files iostream.h and fstream.h contain
definitions of stream classes.

EDUCATION FOR A FAST CHANGIN

Procedural vs. ObjectOriented Code


Read the specification of the
software you want to build.
Underline the verbs if you are
after procedural code, the nouns if
you aim for an object-oriented
program.
Brady Gooch, What is and Isnt Object
Oriented Design, 1989.

EDUCATION FOR A FAST CHANGIN

Verification of
Software
Correctness
Testing
Debugging
Program verification

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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

...

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Design for Correctness

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Design Review Activities


Deskchecking: tracing an execution of
a design or program on paper
Walk-through: a verification method
in which a team performs a manual
simulation of the program or design.
Inspection: a verification method in
which one member of a team reads
the program or design line by line an
the others point out errors.

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

Tasks within each test


case:
determine inputs that demonstrate the goal.
determine the expected behavior for the
input.
run the program and observe results.
compare expected behavior and actual
behavior. If they differ, we begin debugging.

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Life-Cycle Verification
Activities:

Analysis
Design
Code
Test
Delivery
Maintenance

EDUCATION FOR A FAST CHANGIN

Programs and
Programming
The computer only knows what is told

through programs, so they must be


accurate and very specific.
The process of creating programs is
programming.
A program follows a step-by-step logic
algorithm to solve a problem.

Note: never a attempt to program


before developing an algorithm that
solve the problem

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Programming
Language

Level of Computer Languages

Low level : at the level of the computer


Binary format

Intermediate Level : close to computer language


but uses English language
Assembler

High Level: at the level of programmer using


English words and clearly defined syntax
Translated to binary to implement it
Need software program for conversion

EDUCATION FOR A FAST CHANGIN

Programming
Language
Graphical Representation

Total = 0
A=1
B=2
Total = A + B

Translation
Program

0110101011
0100101
01011010
01010010

EDUCATION FOR A FAST CHANGIN

High level to Binary


Compiler
program that translates a high-level language
program, such as a C++ program, into a
machine-language program that the computer
can directly understand and execute

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.

EDUCATION FOR A FAST CHANGIN

EDUCATION FOR A FAST CHANGIN

EDUCATION FOR A FAST CHANGIN

Programming
Language

Types of Computer Language

Procedural: Monolithic program that runs


from the start to finish with no
intervention from user other than input.
C
Basic

Object Oriented/Event Driven: programs


that use objects which responds to events;
Visual Basic

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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?

EDUCATION FOR A FAST CHANGIN

Developing an
Algorithm
1. Identify the Inputs
2. Identify the Processes
3. Identify the Outputs
4. Develop a HIPO Chart
5. Identify modules

EDUCATION FOR A FAST CHANGIN

1. Identify the Inputs


What data do I need?
How will I get the data?
In what format will the
data be?

EDUCATION FOR A FAST CHANGIN

2. Identify the
Processes

How can I manipulate


data to produce
meaningful results?
Data vs. Information

EDUCATION FOR A FAST CHANGIN

3. Identify the Outputs

What outputs do I need


to return to the user?
What format should the
outputs take?

EDUCATION FOR A FAST CHANGIN

4. Develop a HIPO Chart


Hierarchy of Inputs Processes & Outputs

EDUCATION FOR A FAST CHANGIN

5. Identify Relevant
Modules

How can I break larger problems into


smaller, more manageable pieces?
What inputs do the modules need?
What processes need to happen in
the modules?
What outputs are produced by the
modules?

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

Importance of
Algorithm

Second, algorithms serve as the


framework to which the actual
solution is patterned after. This
guides the individual in the process
of deriving the solution, thus
saving time and effort as compared
to having one jump immediately to
this stage without any plan.

EDUCATION FOR A FAST CHANGIN

Importance of
Algorithm

Lastly, algorithms can become


generic templates to which other
issues may refer to for solutions. If
properly documented or easily
recalled, an algorithm used to
solve one problem can guide the
individual in resolving another one
of similar nature.

EDUCATION FOR A FAST CHANGIN

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

EDUCATION FOR A FAST CHANGIN

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.

EDUCATION FOR A FAST CHANGIN

You might also like