Introduction and Performance Analysis
Introduction and Performance Analysis
3
INTRODUCTION
•DATA SRUCTURE
• Data: Raw facts about an objects.
14
Need of Data Structure
• As applications are getting complexed and amount of data is increasing day by
✓ Processor speed: To handle very large amount of data, high speed processing is
required, but as the data is growing day by day to the billions of files per entity,
✓ Data Search: Consider an inventory size of 106 items in a store, If our application
needs to search for a particular item, it needs to traverse 106 items every time,
web server, then there are the chances that a very large server can be failed during
that process
DEFINITION OF DATA STRUCTURE:
Data Structures
Factors Affecting Performance of a
Program
Data Structures
Choice of Data Structure
Data Structures
Example
Contd…
Data Structures
Choice 1
Data Structures
Choice 1
Contd…
Data Structures
Choice 2
Data Structures
Types of Data Structures
Data Structures
Linear Data Structures
Data Structures
Non-linear Data Structures
Data Structures
ALGORITHMS
Definition:
An algorithm consists of a set of explicit and unambiguous, finite steps
when carrying out for a given set of initial condition ,produce
corresponding output and terminate in a finite time.
Characteristics of Algorithm
• Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or phases), and their inputs/outputs
should be clear and must lead to only one meaning.
• Output − An algorithm should have well-defined outputs and should match the desired output.
• Independent − An algorithm should have step-by-step directions, which should be independent of any programming
code.
A program MUST be systematically and properly
designed before coding begins. This design process
results in the construction of an ALGORITHM.
Algorithm
OR
• Algorithm:
• Talking to humans, easy to understand
• In plain (English) language
• Program:
• Talking to computer (compiler)
• Can be regarded as a “formal expression” of an algorithm
From Algorithm to Program
PROGRAM
ALGORITHM a set of instructions which
are commands to computers
a sequence of instructions
describing how to do a to perform specific
task (or process) operations on data
Algorithm & Program
Algorithm Program
• A step‐by‐step problem‐solving • A program is a set of instructions
procedure which are commands to computers to
perform specific operations on data.
• A sequence of instruction that tell
how to solve a particular problem.
• Instructions within a program are
• A set of instruction for solving a organized in such a way, when the
problem, especially on a computer. program is run on a computer; it
• A computable set of steps to achieve results in the solution of a problem.
a desired result.
• Written in pseudo code or flowchart. • Written in any programming language
Program Development Life Cycle
i. Problem solving Phases
Consist of problem definition and algorithm design
Phase 1: Problem Definition (Analysis)
Phase 2: Algorithm design
Yes IF No
(test
statement
condition)
LOOP
THEN ELSE (statement)
(statement) (statement)
statement
DO WHILE Yes
(test
condition)
No
DO WHILE
Design an algorithm to find the area of a rectangle
The formulas: area = length * width
calculate area
area
End
Sequence Example
Flowchart
Simple
Simple Design
Design Modular Design Modular Sub-Module
Design
Start
start Start
Read Read
num1 num2
Return
Read num1,
get_input()
num2
Start
Return
Print sum display_output()
Start
Return
Pseudo Code Style
Style 1 Style 2 Style 3 (Modular design)
3. calculate_sum()
sum = num1 + num2
4. display_output()
Print sum
Why Algorithm is Important?
• Describe the steps needed to perform a computation
Data Structures
Big-Oh Notation
• The Big-Oh notation defines that for a large number of input ‘n’,
the growth rate of an algorithm T(n) is of the order of a function ‘g’
of ‘n’ as indicated by the following relation:
T(n) = O(g(n))
Data Structures
Simple Statement
Data Structures
Sequence Structure
Data Structures
Sequence Structure
Data Structures
The Loop Structure
T(n) = O(N)
Data Structures
Nested Loop
Data Structures
if-then-else Structure