Data Structures Using C++ by DR Varsha Patil: Oxford University Press © 2012
Data Structures Using C++ by DR Varsha Patil: Oxford University Press © 2012
Data Structures Using C++ by DR Varsha Patil: Oxford University Press © 2012
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Understand the well-defined, clear, and simple approach
of program design
Learn fundamental aspects of algorithm and
its characteristics
Learn basic concepts such as data, data type,
data object, data structure, etc.
Know the power of Abstract Data Type (ADT)
Study about Software Development Life Cycle
(SDLC)
2
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Program Data
Computer
Output
Fig 1: Processing a
Program
3
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Machine Language
Assembly Language
High-level Language
4
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
OOP is used to model the real world through objects
Object-oriented decomposition views software as a set of
well-defined objects that model entities in the
application domain
These objects interact with each other to form a
software system
5
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Data
Data Type
Data Object
Data structure
Abstract Data Types (ADT)
6
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Data is nothing but a piece of information
Data input, data manipulation (or data
processing) and data output are the themes of
computer
The address of the it h element is calculated
by the following formula
Atomic Data
Composite Data
7
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Data type is a term that specifies the type of data that a
variable may hold in the programming language
8
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
A Data Object represents a container for data values
a place where data values may be stored
and later retrieved
Data Object is runtime instance of data structure
9
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
A Data Structure is
A combination of elements each of which is either a
data type or another data structure and
A set of associations or relationships
(structures) involving the combined elements
A data structure is a set of domains D, a designated
domain d Î D, a set of function F, and a set of axioms
A
The triple (D, F, A) denotes the data structure d and it
will usually be written as d
10
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
An Abstract Data Type is a data declaration packaged
together with the operations that are meaningful for
the data type
Abstract Data Type includes declaration of data,
implementation of operations, and encapsulation of
data and operations
11
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Primitive and Non-Primitive Data Structures
Linear and Non-linear Data Structures
Static and Dynamic
Persistent and Ephemeral Data Structures
Sequential Access and Direct Access Data
Structures
12
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
A Data Structure is said to be linear
if its elements form a sequence or a linear
list
Linear Data Structure, every data element has
unique successor and unique predecessor
13
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
In non-linear data structures, every data
element may have more than one predecessor
as well as successor
Elements do not form any particular linear
sequence
14
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Characteristics of Algorithm
Algorithmic
Design Tools
Pseudo Code
Flow chart
15
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
The step-by-step solution is called an
Algorithm system and
Algorithm is independent of
The real world
computer performance
programming of any software depends on two
language
things
The algorithm chosen, and
The suitability andefficiency of various layers of
implementation
16
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Input
Output
Unambiguous Steps
Finiteness
Effectiveness
17
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
How to devise algorithms
How to validate
algorithms
How to analyze algorithms
18
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Pseudo code Notations
Algorithm Header
Purpose
Conditions and Return
Statement
Statement Numbers
Variables
Statement Constructs
Sub Algorithms
19
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Sequence
Decision
Repetition
20
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Figure 2: Sequence construct
21
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
If a condition is true,
Algorithm
Then Purpose :Comparing two numbers
Pre: None
Post: None
Series of Actions Return: None
1) Read two
numbers
Num1 and
Else Num2
2) If Num1 >
Num2
Series of Actions a. Then Print
Num1
Example
b. Else Print
Num2
3) Stop
Figure 3: Decision Construct
22
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
If a condition is true,
Algorithm
Then Purpose :Comparing two numbers
Pre: None
Post: None
Series of Actions Return: None
1) Read two
numbers
Num1 and
Num2
2) If Num1 >
Num2
Series of Actions a. Then Print
Num1
Example
b. Else Print
Num2
3) Stop
Figure 3: Decision Construct
23
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Figure 4: Repetition Construct
24
Data Structures in C++ by Dr. Varsha Patil Oxford University Press ©
Relationship between Data,
Data Structures, and
Algorithms
A data structure represents a set of data items
with a specific relationship between them.
The success of a software project often depends
upon the choices made in the representation
of data and algorithms designed to process the
data
The proper choice of a data structure can be a
key point in the design of many algorithms
25
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Specification
Implementation
26
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
A very effective tool to show the logic flow of a program
A flow chart is a pictorial representation of an
algorithm.
It hides all of the details of an algorithm by giving
the picture;
It shows how the algorithm flows from beginning to end
27
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Figure 5: Flow chart for adding
three
28
Data Structures Using C++ by Dr Varsha Patil numbers Oxford University Press © 2012
Complexity of Algorithms
Space Complexity
Time Complexity
Computing Time Complexity of
Algorithm
Big-O Notation
29
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Amount of computer memory required during the
program execution, as a function of the input size
Space complexity measurement which is space
requirement of an algorithm can be done at two different
times:
Compile time and
Execution time
30
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Compile Time Space Complexity is defined as
the storage requirement of a program at compile time
31
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
If program is recursive or uses dynamic variables or
dynamic data structure then there is a need to determine
space complexity at runtime
The memory requirement is summation of the
Program Space
Data Space And
Stack Space
32
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Time Complexity of an algorithm is a measure of how
much time is required to execute an algorithm for a given
number of inputs
Time Complexity T(P) is the time taken by program P
and the sum of the compile and execution time
33
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Worst Case
Complexity of the algorithm is the function defined
by the maximum number of steps taken on any instance
of size n
Best Case
Complexity of the algorithm is the function defined
by the minimum number of steps taken on any instance
of size n
Average Case
Complexity of the algorithm is the function defined
by an average number of steps taken on any instance of
size n
34
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
The total time taken by the algorithm or program is
calculated using the sum of the time taken by each of
executable statement in algorithm or program
Time required by each statement depends on
Time required for executing it once
Number of times the statement is executed
35
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Software Engineering
Software Engineering is the
establishment and use of sound
engineering methods
and principles to obtain reliable software
that works on real machines
A fundamental concept in Software
Engineering is the Software
Development Life Cycle (SDLC)
36
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Software Engineering
Analysis Phase
Design Phase
Implementation Phase
Testing Phase
Verification
37
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Software Engineering
38
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Analysis Phase
Define the User
Define the Needs
Define the Requirements
Define the Methods
39
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Design Phase
Modularity
The design phase uses a very
well- established principle called Modularity
The whole package is divided into small
modules
40
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Implementation Phase
Tools
Flowchart
Pseudo Code
Coding
41
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Testing Phase
Testing Phase
Once the programs have been written, they must
be tested.
There are two types of testing:
Black Box
White Box
42
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Verification
Program verification is a process to prove
that the program does what it is intended to
do
It is said that 'even verification must be
verified'
This means, along with system, tests made
are to be verified
Also, every software quality must be verified
43
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
KEY
TERMS
DATA
DATA TYPE
DATA OBJECT
DATA STRUCTURE
ABSTRACT DATA TYPE
LINEAR DATA STRUCUTRE
NON LINEAR DATA STRUCTURE
ALGORITHM
ASSEMBLER
COMPILER
PROGRAM
PSEUDOCODE
FLOWCHART
SOFTWARE ENGINEERING
44
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Summar
y
Computer is a programmable data processing machine that accepts
input; instructions to process input (program) and generates
required output. Data and program are stored in computer’s
memory. A program is written in computer’s language.
The art of programming consists of designing or choosing
algorithms and expressing them in a programming language. An
algorithm is a stepwise description of action which leads the
problem from its start state to its goal state
One of the common tools used to define algorithms is pseudo
code. Pseudo code is an English-like representation of the code
required for an algorithm. It is part of English, part structured
code
A very effective tool to show the logic flow of a program is the
flow chart. A flow chart is a pictorial representation of an
algorithm. It hides all of the details of an algorithm by giving the
picture; it shows how the algorithm flows from beginning to end
Program verification is a process to prove that the program does
what it is intended to do
45
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Su m m a ry
Engineering is the establishment and use of
engineering methods and principles to sound
software that works on real machines obtain reliable
46
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Su m m a ry
The various types Software Engineering is the establishment
and use of sound engineering methodologies and the
principle to writing reliable of data structures are:
47
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
Summar
y
There is an intimate relationship between the structuring of data, and
analysis of algorithms. In fact, a data structure and an algorithm
should be thought of as a one single unit, neither one along making
sense without the other. · Algorithms heavily depend on the
organization of data
48
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012
49
Data Structures Using C++ by Dr Varsha Patil Oxford University Press © 2012