SlideShare a Scribd company logo
1 of 65
Download to read offline
DATA STRUCTURES
MODULE 1
For More Visit : KtuQbank.com | Fair Use Policy
Module 1
ā€¢Basic Concepts of Data Structures
ā€¢ System Life Cycle, Algorithms, Performance
Analysis, Space Complexity, Time
Complexity, Asymptotic Notation,
Complexity Calculation of Simple Algorithms
For More Visit : KtuQbank.com | Fair Use Policy
Data Structure
ā€¢ Data Structure is a way of collecting and organising data in
such a way that we can perform operations on these data in an
effective way.
ā€¢ It represents the knowledge of data to be organized in memory.
ā€¢ A data structure is a particular way of organizing data in a
computer
ā€¢ A data structure is a specialized format for organizing,
processing, retrieving and storing data.
For More Visit : KtuQbank.com | Fair Use Policy
Data Structure
ā€¢ Data: Data is a raw and unorganized fact that is required to be
processed to make it meaningful
ā€¢ Information: Information is a set of data which is processed in a
meaningful way according to the given requirement.
For More Visit : KtuQbank.com | Fair Use Policy
For More Visit : KtuQbank.com | Fair Use Policy
For More Visit : KtuQbank.com | Fair Use Policy
For More Visit : KtuQbank.com | Fair Use Policy
Operations on Data Structures
ā€¢ The basic operations that are performed on data structures are
as follows:
1. Insertion
2. Deletion
3. Traversal
4. Sorting
5. Merging
For More Visit : KtuQbank.com | Fair Use Policy
Operations on Data Structures
ā€¢ Insertion means addition of a new data element in a data structure.
ā€¢ Deletion means removal of a data element from a data structure if it
is found.
ā€¢ Searching involves searching for the specified data element in a data
structure.
ā€¢ Traversal of a data structure means processing all the data elements
present in it.
ā€¢ Arranging data elements of a data structure in a specified order is
called sorting.
ā€¢ Combining elements of two similar data structures to form a new
data structure of the same type, is called merging.
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle
ā€¢ The system life cycle is a series of stages that are worked through
during the development of a new information system.
ā€¢ A lot of time and money can be wasted if a system is developed that
doesnā€™t work properly or do exactly what is required of it.
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle-5 Phases
ā€¢ Requirements
ā€¢ Design
ā€¢ Analysis
ā€¢ Coding
ā€¢ Verification
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle
Requirements- Understanding the information you are given (the
input) and what results you are to produce (the output).
ā€¢ A rigorous description of the input and output which covers all
cases.
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle
Design- There are several data objects (such as a maze, a polynomial,
or a list of names).
ā€¢ For each object there will be some basic operations to perform on it
(such as print the maze, add two polynomials, or find a name in the
list).
ā€¢ Assume that these operations already exist in the form of procedures.
ā€¢ Write an algorithm which solves the problem according to the
requirements.
ā€¢ Use a notation which is natural to the way you wish to describe the
order of processing.
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle
Analysis- If there is another algorithm which solves the same problem,
write it down.
ā€¢ Next, try to compare these two methods.
ā€¢ It may already be possible to tell if one will be more desirable than
the other.
ā€¢ If you can't distinguish between the two, choose one to work on for
now and we will return to the second version later
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle
Refinement and coding
ā€¢ Choose representations for data objects (a maze as a two dimensional
array of zeros and ones, a polynomial as a one dimensional array of
degree and coefficients, a list of names possibly as an array)
ā€¢ Write algorithms for each of the operations on these objects.
ā€¢ The order in which you do this may be crucial, because once you
choose a representation, the resulting algorithms may be inefficient.
For More Visit : KtuQbank.com | Fair Use Policy
System Life Cycle
ā€¢ Verification
ā€¢ Verification is concerned about the correctness of process
For More Visit : KtuQbank.com | Fair Use Policy
Algorithm
ā€¢ Algorithm is a step by step procedure, which defines a set of
instructions to be executed in certain order to get the desired output.
ā€¢ Algorithms are generally created independent of underlying
languages, i.e. an algorithm can be implemented in more than one
programming language.
For More Visit : KtuQbank.com | Fair Use Policy
Characteristics of an Algorithm
ā€¢ Unambiguous āˆ’ Algorithm should be clear and unambiguous.
ā€¢ Each of its steps or phases, and their input/outputs should be clear and
must lead to only one meaning.
ā€¢ Input āˆ’ An algorithm should have 0 or more well defined inputs.
ā€¢ Output āˆ’ An algorithm should have 1 or more well defined outputs, and
should match the desired output.
ā€¢ Finiteness āˆ’ Algorithms must terminate after a finite number of steps.
ā€¢ Feasibility āˆ’ Should be feasible with the available resources.
ā€¢ Independent āˆ’ An algorithm should have step-by-step directions which
should be independent of any programming code.
For More Visit : KtuQbank.com | Fair Use Policy
Algorithm
ā€¢ Finite step- by-step sequence of instructions for solving a
particular problem.
ā€¢ Writing and executing programs and then optimizing them will be
effective for smaller programs.
ā€¢ Optimization of a program is directly related with the algorithm
design.
ā€¢ For a large program, each part of the program must be well
organized before writing the program.
ā€¢ There are few steps of refinement involved when a problem is
converted to program- called stepwise refinement method.
For More Visit : KtuQbank.com | Fair Use Policy
Algorithm
ā€¢ We can write an informal algorithm- If we have an appropriate
mathematical model for a problem.
ā€¢ The initial version of the algorithm will contain general statements,
i.e., informal instructions.
ā€¢ Then we convert this informal algorithm to formal algorithm- with
more definite instructions by applying any programming language
syntax and semantics.
ā€¢ Finally a program can be developed by converting the formal
algorithm by a programming language manual.
For More Visit : KtuQbank.com | Fair Use Policy
Algorithm
ā€¢ So, there are several steps to reach a program from a mathematical
model.
ā€¢ In every step, there is a refinement(or conversion).
ā€¢ That is to covert an informal algorithm to a program, we must go
through several stages
ā€¢ Three steps in refinement process:
For More Visit : KtuQbank.com | Fair Use Policy
Algorithm
ā€¢ In the first stage, modeling, we try to represent the problem using
an appropriate mathematical model such as a graph, tree etc.
ā€¢ At this stage, the solution to the problem is an algorithm expressed
very informally.
ā€¢ During next stage, the algorithm is written in pseudo-language (or
formal algorithm) which is a mixture of programming language
constructs and less formal English statements.
ā€¢ Here the operations to be performed on the various types of data
become fixed.
ā€¢ In the final stage, we choose an implementation and write the
procedures for the various operations on that type. The remaining
informal statements in the algorithm are replaced by C/C++ codes.
For More Visit : KtuQbank.com | Fair Use Policy
Analysis of algorithms
ā€¢ After designing an algorithm, it has to be checked and its correctness needs
to be predicted.
ā€¢ This is done by analyzing the algorithm.
ā€¢ An algorithm is analyzed with reference to the following:
ā€¢ Correctness
ā€¢ Execution time
ā€¢ Amount of memory used
ā€¢ Simplicity and clarity
For More Visit : KtuQbank.com | Fair Use Policy
Analysis of algorithms
ā€¢ Algorithm Analysis Efficiency of an algorithm can be analyzed at two
different stages, before implementation and after implementation, as
mentioned below
ā€¢ A priori analysis
ā€¢ A posterior analysis
For More Visit : KtuQbank.com | Fair Use Policy
Algorithm Complexity
ļƒ˜Efficiency of algorithms
ļƒ˜Algorithm complexity is a measure which evaluates the order
of the count of operations, performed by a given or algorithm
as a function of the size of the input data.
ļƒ˜Complexity is a rough approximation of the number of
steps necessary to execute an algorithm.
1) Space complexity
2) Time complexity
For More Visit : KtuQbank.com | Fair Use Policy
ā€¢ Complexity can
be constant, logarithmic, linear, n*log(n), quadrat
ic, cubic, exponential, etc.
For More Visit : KtuQbank.com | Fair Use Policy
Analysis of algorithms
ā€¢ Best case, worst case and average case of an algorithm
ā€¢ The best case implies minimum execution time that the algorithm would demand.
ā€¢ The worst case implies maximum execution time.
ā€¢ The average case indicates the behavior of the algorithm in an average situation.
For More Visit : KtuQbank.com | Fair Use Policy
Asymptotic complexity
ā€¢ Complexity of an algorithm is usually a function of n.
ā€¢ Behavior of this function is usually expressed in terms of one or more
standard functions.
ā€¢ Expressing the complexity function with reference to other known
functions is called asymptotic complexity.
ā€¢ Three basic notations are used to express the asymptotic complexity- Big-
oh(O), Big-omega(Ī©), Theta(Īø)
For More Visit : KtuQbank.com | Fair Use Policy
ā€¢ Asymptotic notations are the mathematical notations used to
describe the running time of an algorithm when the input tends
towards a particular value or a limiting value.
ā€¢ For example: In bubble sort, when the input array is already sorted,
the time taken by the algorithm is linear i.e. the best case.
ā€¢ But, when the input array is in reverse condition, the algorithm takes
the maximum time (quadratic) to sort the elements i.e. the worst
case.
ā€¢ When the input array is neither sorted nor in reverse order, then it
takes average time. These durations are denoted using asymptotic
notations.
ā€¢ There are mainly three asymptotic notations: Theta notation, Omega
notation and Big-O notation.
For More Visit : KtuQbank.com | Fair Use Policy
Big oh (O) Notations
ā€¢ Formal method of expressing the upper bound of an algorithmā€™s
running time.
ā€¢ i.e. it is a measure of longest amount of time it could possibly take
for an algorithm to complete.
ā€¢ It is used to represent the worst case complexity.
Definition:
ā€¢ For non negative functions f(n) and g(n), f(n)=O(g(n))
if there exist an integer n0 and a constant C>0 such
that for all integers n>n0, f(n) ā‰¤ C. g(n) then
ā€¢ f(n)=O(g(n)) implies the behavior of f(n) with
reference to another function g(n) and it signifies
that g(n) is the upper bound of f(n)
30
For More Visit : KtuQbank.com | Fair Use Policy
Big oh (O) Notations
Graphical representation
It is represented mathematically as 0 ā‰¤ f (n) ā‰¤ C. g(n))
ā€¢ For all values of n to the right of n0, the value of f(n) is on or below
C. g(n)
31
O(g(n)) = { f(n): there exist positive constants c
and n0 such that 0 ā‰¤ f(n) ā‰¤ cg(n) for all n ā‰„ n0 }
For More Visit : KtuQbank.com | Fair Use Policy
Omega Notation (Ī©-notation)
ā€¢ Omega notation represents the lower bound of the running time
of an algorithm.
ā€¢ Thus, it provides best case complexity of an algorithm.
For More Visit : KtuQbank.com | Fair Use Policy
Ī©(g(n)) = { f(n): there exist positive constants c and
n0 such that 0 ā‰¤ cg(n) ā‰¤ f(n) for all n ā‰„ n0 }
The above expression can be described as a function f(n) belongs to the set Ī©(g(n)) if there exists a
positive constant c such that it lies above cg(n), for sufficiently large n.
For any value of n, the minimum time required by the algorithm is given by Omega Ī©(g(n))
For More Visit : KtuQbank.com | Fair Use Policy
Theta Notation (Ī˜-notation)
ā€¢ Theta notation encloses the function from above and below.
Since it represents the upper and the lower bound of the
running time of an algorithm, it is used for analyzing the
average case complexity of an algorithm.
For More Visit : KtuQbank.com | Fair Use Policy
Ī˜(g(n)) = { f(n): there exist positive constants c1, c2 and n0 such that 0 ā‰¤
c1g(n) ā‰¤ f(n) ā‰¤ c2g(n) for all n ā‰„ n0 }
The above expression can be described as a function f(n) belongs to the set Ī˜(g(n)) if there exist
positive constants c1 and c2 such that it can be sandwiched between c1g(n) and c2g(n), for
sufficiently large n.
For More Visit : KtuQbank.com | Fair Use Policy
Complexity of an algorithm(evaluation of
algorithm)
ā€¢ The complexity of an algorithm is the function, which give the running
time or storage space in terms of input size.
ā€¢ Space Complexity: How much space an algorithm needs to
complete its task.
ā€¢ Time Complexity: Running time of a program as a function of
input size.
ā€¢ Analysis of algorithms is the determination of the amount of
time and space resources required to execute it.
For More Visit : KtuQbank.com | Fair Use Policy
Space Complexity
ļƒ˜Space complexity = The amount of memory required by an
algorithm to run to completion
ā€¢ Two part :
1. Fixed part: independent of Input & output characteristics:
ļƒ¼Instruction space
ļƒ¼space for variables
ļƒ¼space for constants & so on
2. Variable part: Space needed by variables, whose size is dependent on the
size of the problem:
ļƒ¼Space needed by referenced variables,
ļƒ¼recursion stack space,etc
L1.37
For More Visit : KtuQbank.com | Fair Use Policy
Calculation
S(p)=C+Sp
ļƒ˜Let p be the algorithm
ļƒ˜S(p) :space complexity
ļƒ˜C:fixed space
ļƒ˜ Sp:variable space
L1.38
For More Visit : KtuQbank.com | Fair Use Policy
Example 1
void main()
{
int x,y,z,sum;
printf(ā€œenter 3 numbersā€);
scanf(ā€œ%d%d%dā€,&x,&y,&z);
Sum=x+y+z;
Printf(ā€œ%dā€,sum);
}
ā€¢ Variables used are:
ā€¢ Variable x: 1 word
ā€¢ Variable y: 1 word
ā€¢ Variable z: 1 word
ā€¢ Variable sum: 1 word
ā€¢ Total space:4 word
For More Visit : KtuQbank.com | Fair Use Policy
Example 2
Algoritm Sum(a,n)
{ S=0;
for i=1 to n
S=s+a[i];
Return s; }
ā€¢ Size variable n:1 word
ā€¢ Loop variable i:1 word
ā€¢ Sum variable s:1 word
ā€¢ Array a values: n words
ā€¢ Total space:n+3 words
L1.40
For More Visit : KtuQbank.com | Fair Use Policy
Example 3
int main()
{
int a = 5,b = 5,c;
c = a + b;
printf("%d", c);
}
For More Visit : KtuQbank.com | Fair Use Policy
Example 4
Algoritm Sum(a,n)
{ S=0;
for i=1 to n
for j=1 to m
S=s+a[i][j];
}
ā€¢ Size variable n:1 word
ā€¢ Loop variable i:1 word
ā€¢ Sum variable s:1 word
ā€¢ Array a values: n*m words
ā€¢ Total space:nm+3 words
L1.42
For More Visit : KtuQbank.com | Fair Use Policy
Time complexity:
ā€¢ How much time needed for the completion of a program
2 components:
1. Compile time :Does not depend on instance characteristics.
2. Run time:Dependent on particular problem instance
ā€¢ Time complexity :T(P)=C+Tp
ā€¢ T(p):time complexity of algorithm P
ā€¢ C:Compile time
ā€¢ Tp :run time
L1.43
For More Visit : KtuQbank.com | Fair Use Policy
Time Complexity: Frequency count
ļƒ˜Time complexity can be calculated by counting the number of steps
each statement in the program executes
Eg:
ā€¢ Comments-0 steps
ā€¢ Assignment statement-1 step
ā€¢ Condition statement-1 step
ā€¢ Loop condition for ā€˜nā€™ times-(n+1) steps
ā€¢ Body of loop-N steps
L1.44
For More Visit : KtuQbank.com | Fair Use Policy
Frequency count
ā€¢ Frequency count is, the number of times the statement is
executed in the program.
ā€¢ Letā€™s consider some of the program segments
ā€¢ Program Segment A:
ā€¦
x = x+2
ā€¦
For More Visit : KtuQbank.com | Fair Use Policy
Frequency count
ā€¢ Program Segment B:
ā€¦
for k =1 to n do
x = x+2
end
ā€¦
ā€¢ Program Segment C:
ā€¦
for j= 1 to n do
for x = 1 to n do
x = x+2
end
end
For More Visit : KtuQbank.com | Fair Use Policy
Frequency count
ā€¢ The frequency count of the statement in the program
segment A is 1.(It gets executed once)
ā€¢ In the program segment B, the frequency count of the
statement is n, since the for loop in which the statement
is embedded executes n(n>=1) times.
ā€¢ In the program segment C, the statement is executed
n2(n>=1) times, since the statement is embedded in a
nested for loop, executing n times each.
For More Visit : KtuQbank.com | Fair Use Policy
Example 1
Void hello()
{
for(i=1; i <=n; i++) ļƒ n+1 times
{
print(ā€Helloā€; ); ļƒ n times
}
}
ā€¢ Add all statement:n+1+n=2n+1 times
For More Visit : KtuQbank.com | Fair Use Policy
Example 2
float sum(float a[ ], int n)
{
float temp = 0; ļƒ 1 times
int i;
for(i=0; i <n; i++) ļƒ n+1 times
{
temp=temp+a[i]; ļƒ  n times
}
return (temp); ļƒ 1 times
}
Total time: 2n+3 times
For More Visit : KtuQbank.com | Fair Use Policy
Example 3
Void add ()
{
int i, j,m,n,a[];
for (i = 0; i < n; i++) ļƒ n+1 times
for (j=0; j< m; j++) ļƒ n(m+1) times
s=s+a[i][j]; ļƒ n*m times
}
Total:n+1+nm+n+nm=2nm+2n+1
For More Visit : KtuQbank.com | Fair Use Policy
Different programming methodologies
ā€¢ Deals with different methods of designing programs.
ā€¢ Modular programming:
ā€¢ Procedural programming
ā€¢ The focus is entirely on writing code(functions)
ā€¢ Data is passive
ā€¢ Any code may access the contents of any data structure passed
to it- i.e. no encapsulation.
ā€¢ Here programs are written as functions
ā€¢ Minimal interaction between functions.
ā€¢ Easy to detect error and to test it in isolation
ā€¢ It discourages the use of control variables and flags in
parameters.
ā€¢ It encourages splitting the functionality into two types
ā€¢ Master and slave
ā€¢ Two methods Modular programming:
ā€¢ Top-Down and Bottom-Up
For More Visit : KtuQbank.com | Fair Use Policy
Types of Programming Methodologies
1. Procedural Oriented Programming
2. Object-Oriented Programming
3. Structured Programming
4. Modular Programming
For More Visit : KtuQbank.com | Fair Use Policy
1)PROCEDURAL ORIENTED PROGRAMMING 2)OBJECT ORIENTED PROGRAMMING
In procedural programming, program is divided into small
parts called functions.
In object oriented programming, program is divided into small
parts called objects.
Procedural programming follows top down approach. Object oriented programming follows bottom up approach.
There is no access specifier in procedural programming.
Object oriented programming have access specifiers like
private, public, protected etc.
Adding new data and function is not easy. Adding new data and function is easy.
Procedural programming does not have any proper way for
hiding data so it is less secure.
Object oriented programming provides data hiding so it
is more secure.
In procedural programming, overloading is not possible. Overloading is possible in object oriented programming.
In procedural programming, function is more important than
data.
In object oriented programming, data is more important than
function.
Procedural programming is based on unreal world. Object oriented programming is based on real world.
Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python, C# etc.
For More Visit : KtuQbank.com | Fair Use Policy
Different programming methodologies
3)Modular programming:
ā€¢ Procedural programming
ā€¢ The focus is entirely on writing code(functions)
ā€¢ Data is passive
ā€¢ No data encapsulation.
ā€¢ Here programs are written as functions
ā€¢ Minimal interaction between functions.
ā€¢ Easy to detect error and to test it in isolation
ā€¢ Two methods Modular programming:
a) Top-Down approach
b) Bottom-Up approach
For More Visit : KtuQbank.com | Fair Use Policy
Modular programming:
a)Top-Down design:
ā€¢ Here a program should be divided into a main module and its
related modules.
ā€¢ Each module should also be divided into sub modules
according to programming style.
ā€¢ The division process continues, until the module consists only
of elementary process that are understood and cannot be
further subdivided.
ā€¢ Here modules are arranged in a hierarchical manner.
ā€¢ Here each module have single entry and single exit point.
ā€¢ In C, It is done using function.
For More Visit : KtuQbank.com | Fair Use Policy
Modular programming:
ā€¢ Top-Down algorithm design:
For More Visit : KtuQbank.com | Fair Use Policy
Modular programming:
ā€¢ Bottom-up algorithm design:
ā€¢ Opposite of top-down design.
ā€¢ Starting the design with specific modules and build them into
more complex structures, ending at the top.
ā€¢ Widely used in testing.
ā€¢ Here lowest level functions are written and tested first.
ā€¢ This process continues, moving up the level, until the main
function is tested.
For More Visit : KtuQbank.com | Fair Use Policy
S.NO. TOP DOWN APPROACH BOTTOM UP APPROACH
1.
In this approach We focus on breaking up the
problem into smaller parts.
In bottom up approach, we solve smaller problems and integrate
it as whole and complete the solution.
2.
Mainly used by structured programming
language such as COBOL, Fortan, C etc.
Mainly used by object oriented programming language such as
C++, C#, Python.
3.
Each part is programmed separately therefore
contain redundancy.
Redundancy is minimized by using data encapsulation and data
hiding.
4.
In this the communications is less among
modules.
In this module must have communication.
5.
It is used in debugging, module
documentation, etc.
It is basically used in testing.
6.
In top down approach, decomposition takes
place.
In bottom up approach composition takes place.
7.
In this top function of system might be hard to
identify.
In this sometimes we can not build a program from the piece we
have started.
8. In this implementation details may differ. This is not natural for people to assemble.
For More Visit : KtuQbank.com | Fair Use Policy
For More Visit : KtuQbank.com | Fair Use Policy
Programming methodologies
ā€¢ Structured programming:
ā€¢ It is a Programming style.
ā€¢ Not programming with structures, but by using following types of codes structures to
write programs:
ā€¢ 1. Sequence of sequentially executed statements.
ā€¢ 2. Conditional execution of statements(i.e. ā€œifā€ statements)
ā€¢ 3. Looping or iteration(i.e. ā€œfor, doā€¦while and whileā€ stmts)
ā€¢ 4. Structured subroutine calls(i.e. functions)
For More Visit : KtuQbank.com | Fair Use Policy
ā€¢ Structured programming:
ā€¢ Here, the following language usage is forbidden(not allowed)
ā€¢ 1. GoTo statements
ā€¢ ā€œBreakā€ or ā€œContinueā€ out of the middle of loops
ā€¢ Multiple exit points or multiple ā€œreturnā€ statements to a
function/ procedure/subroutine
ā€¢ Multiple entry points to a function/ procedure/subroutine
ā€¢ In structured programming, there is a great risk that the
implementation details of many data structures have to be
shared between functions and thus globally exposed.
ā€¢ This tempts other functions to use there implementation
details, there by creating unwanted dependencies between
different parts of the program.
For More Visit : KtuQbank.com | Fair Use Policy
ā€¢ Structured programming:
ā€¢ The main disadvantage is that all decisions made from the start
of the project depends directly or indirectly on the high-level
specification of the application.
ā€¢ This specification tends to change over time.
ā€¢ So, there is a great risk that, large part of the application need to
be rewritten.
For More Visit : KtuQbank.com | Fair Use Policy
For More Visit : KtuQbank.com | Fair Use Policy
For More Visit : KtuQbank.com | Fair Use Policy
THANK YOU
For More Visit : KtuQbank.com | Fair Use Policy

More Related Content

Similar to DS M1 full - KQB KtuQbank.pdf

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
Ā 
Structure system analysis and design method -SSADM
Structure system analysis and design method -SSADMStructure system analysis and design method -SSADM
Structure system analysis and design method -SSADMFLYMAN TECHNOLOGY LIMITED
Ā 
Requirement analysis and UML modelling in Software engineering
Requirement analysis and UML modelling in Software engineeringRequirement analysis and UML modelling in Software engineering
Requirement analysis and UML modelling in Software engineeringsnehalkulkarni74
Ā 
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPURCleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPURNA000000
Ā 
Decision table
Decision tableDecision table
Decision tablejeebala
Ā 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptxSayedMohdAsim2
Ā 
Management Information system
Management Information systemManagement Information system
Management Information systemCochin University
Ā 
CPP19 - Revision
CPP19 - RevisionCPP19 - Revision
CPP19 - RevisionMichael Heron
Ā 
Alternative Methodologies for Systems Development
Alternative Methodologies for Systems Development Alternative Methodologies for Systems Development
Alternative Methodologies for Systems Development Sunderland City Council
Ā 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.pptMumitAhmed1
Ā 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data typesLavanyaJ28
Ā 
Evolving the Optimal Relevancy Ranking Model at Dice.com
Evolving the Optimal Relevancy Ranking Model at Dice.comEvolving the Optimal Relevancy Ranking Model at Dice.com
Evolving the Optimal Relevancy Ranking Model at Dice.comSimon Hughes
Ā 
Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...
Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...
Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...Lucidworks
Ā 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)Ravinder Kamboj
Ā 

Similar to DS M1 full - KQB KtuQbank.pdf (20)

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
Ā 
Structure system analysis and design method -SSADM
Structure system analysis and design method -SSADMStructure system analysis and design method -SSADM
Structure system analysis and design method -SSADM
Ā 
Requirement analysis and UML modelling in Software engineering
Requirement analysis and UML modelling in Software engineeringRequirement analysis and UML modelling in Software engineering
Requirement analysis and UML modelling in Software engineering
Ā 
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPURCleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Cleanroom Software Engineering By NADEEM AHMED FROM DEPALPUR
Ā 
Decision table
Decision tableDecision table
Decision table
Ā 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
Ā 
Cs 331 Data Structures
Cs 331 Data StructuresCs 331 Data Structures
Cs 331 Data Structures
Ā 
Management Information system
Management Information systemManagement Information system
Management Information system
Ā 
CPP19 - Revision
CPP19 - RevisionCPP19 - Revision
CPP19 - Revision
Ā 
Sad1
Sad1Sad1
Sad1
Ā 
Alternative Methodologies for Systems Development
Alternative Methodologies for Systems Development Alternative Methodologies for Systems Development
Alternative Methodologies for Systems Development
Ā 
Mit16 30 f10_lec01
Mit16 30 f10_lec01Mit16 30 f10_lec01
Mit16 30 f10_lec01
Ā 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
Ā 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
Ā 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
Ā 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
Ā 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
Ā 
Evolving the Optimal Relevancy Ranking Model at Dice.com
Evolving the Optimal Relevancy Ranking Model at Dice.comEvolving the Optimal Relevancy Ranking Model at Dice.com
Evolving the Optimal Relevancy Ranking Model at Dice.com
Ā 
Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...
Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...
Evolving The Optimal Relevancy Scoring Model at Dice.com: Presented by Simon ...
Ā 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
Ā 

Recently uploaded

šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
Ā 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoĆ£o Esperancinha
Ā 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
Ā 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
Ā 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
Ā 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
Ā 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
Ā 
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerAnamika Sarkar
Ā 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
Ā 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
Ā 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
Ā 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
Ā 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
Ā 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
Ā 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
Ā 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
Ā 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
Ā 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
Ā 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
Ā 

Recently uploaded (20)

šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
šŸ”9953056974šŸ”!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
Ā 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
Ā 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Ā 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
Ā 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
Ā 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
Ā 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
Ā 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Ā 
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Ā 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
Ā 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
Ā 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
Ā 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
Ā 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
Ā 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
Ā 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
Ā 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
Ā 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
Ā 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
Ā 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
Ā 

DS M1 full - KQB KtuQbank.pdf

  • 1. DATA STRUCTURES MODULE 1 For More Visit : KtuQbank.com | Fair Use Policy
  • 2. Module 1 ā€¢Basic Concepts of Data Structures ā€¢ System Life Cycle, Algorithms, Performance Analysis, Space Complexity, Time Complexity, Asymptotic Notation, Complexity Calculation of Simple Algorithms For More Visit : KtuQbank.com | Fair Use Policy
  • 3. Data Structure ā€¢ Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. ā€¢ It represents the knowledge of data to be organized in memory. ā€¢ A data structure is a particular way of organizing data in a computer ā€¢ A data structure is a specialized format for organizing, processing, retrieving and storing data. For More Visit : KtuQbank.com | Fair Use Policy
  • 4. Data Structure ā€¢ Data: Data is a raw and unorganized fact that is required to be processed to make it meaningful ā€¢ Information: Information is a set of data which is processed in a meaningful way according to the given requirement. For More Visit : KtuQbank.com | Fair Use Policy
  • 5. For More Visit : KtuQbank.com | Fair Use Policy
  • 6. For More Visit : KtuQbank.com | Fair Use Policy
  • 7. For More Visit : KtuQbank.com | Fair Use Policy
  • 8. Operations on Data Structures ā€¢ The basic operations that are performed on data structures are as follows: 1. Insertion 2. Deletion 3. Traversal 4. Sorting 5. Merging For More Visit : KtuQbank.com | Fair Use Policy
  • 9. Operations on Data Structures ā€¢ Insertion means addition of a new data element in a data structure. ā€¢ Deletion means removal of a data element from a data structure if it is found. ā€¢ Searching involves searching for the specified data element in a data structure. ā€¢ Traversal of a data structure means processing all the data elements present in it. ā€¢ Arranging data elements of a data structure in a specified order is called sorting. ā€¢ Combining elements of two similar data structures to form a new data structure of the same type, is called merging. For More Visit : KtuQbank.com | Fair Use Policy
  • 10. System Life Cycle ā€¢ The system life cycle is a series of stages that are worked through during the development of a new information system. ā€¢ A lot of time and money can be wasted if a system is developed that doesnā€™t work properly or do exactly what is required of it. For More Visit : KtuQbank.com | Fair Use Policy
  • 11. System Life Cycle-5 Phases ā€¢ Requirements ā€¢ Design ā€¢ Analysis ā€¢ Coding ā€¢ Verification For More Visit : KtuQbank.com | Fair Use Policy
  • 12. System Life Cycle Requirements- Understanding the information you are given (the input) and what results you are to produce (the output). ā€¢ A rigorous description of the input and output which covers all cases. For More Visit : KtuQbank.com | Fair Use Policy
  • 13. System Life Cycle Design- There are several data objects (such as a maze, a polynomial, or a list of names). ā€¢ For each object there will be some basic operations to perform on it (such as print the maze, add two polynomials, or find a name in the list). ā€¢ Assume that these operations already exist in the form of procedures. ā€¢ Write an algorithm which solves the problem according to the requirements. ā€¢ Use a notation which is natural to the way you wish to describe the order of processing. For More Visit : KtuQbank.com | Fair Use Policy
  • 14. System Life Cycle Analysis- If there is another algorithm which solves the same problem, write it down. ā€¢ Next, try to compare these two methods. ā€¢ It may already be possible to tell if one will be more desirable than the other. ā€¢ If you can't distinguish between the two, choose one to work on for now and we will return to the second version later For More Visit : KtuQbank.com | Fair Use Policy
  • 15. System Life Cycle Refinement and coding ā€¢ Choose representations for data objects (a maze as a two dimensional array of zeros and ones, a polynomial as a one dimensional array of degree and coefficients, a list of names possibly as an array) ā€¢ Write algorithms for each of the operations on these objects. ā€¢ The order in which you do this may be crucial, because once you choose a representation, the resulting algorithms may be inefficient. For More Visit : KtuQbank.com | Fair Use Policy
  • 16. System Life Cycle ā€¢ Verification ā€¢ Verification is concerned about the correctness of process For More Visit : KtuQbank.com | Fair Use Policy
  • 17. Algorithm ā€¢ Algorithm is a step by step procedure, which defines a set of instructions to be executed in certain order to get the desired output. ā€¢ Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language. For More Visit : KtuQbank.com | Fair Use Policy
  • 18. Characteristics of an Algorithm ā€¢ Unambiguous āˆ’ Algorithm should be clear and unambiguous. ā€¢ Each of its steps or phases, and their input/outputs should be clear and must lead to only one meaning. ā€¢ Input āˆ’ An algorithm should have 0 or more well defined inputs. ā€¢ Output āˆ’ An algorithm should have 1 or more well defined outputs, and should match the desired output. ā€¢ Finiteness āˆ’ Algorithms must terminate after a finite number of steps. ā€¢ Feasibility āˆ’ Should be feasible with the available resources. ā€¢ Independent āˆ’ An algorithm should have step-by-step directions which should be independent of any programming code. For More Visit : KtuQbank.com | Fair Use Policy
  • 19. Algorithm ā€¢ Finite step- by-step sequence of instructions for solving a particular problem. ā€¢ Writing and executing programs and then optimizing them will be effective for smaller programs. ā€¢ Optimization of a program is directly related with the algorithm design. ā€¢ For a large program, each part of the program must be well organized before writing the program. ā€¢ There are few steps of refinement involved when a problem is converted to program- called stepwise refinement method. For More Visit : KtuQbank.com | Fair Use Policy
  • 20. Algorithm ā€¢ We can write an informal algorithm- If we have an appropriate mathematical model for a problem. ā€¢ The initial version of the algorithm will contain general statements, i.e., informal instructions. ā€¢ Then we convert this informal algorithm to formal algorithm- with more definite instructions by applying any programming language syntax and semantics. ā€¢ Finally a program can be developed by converting the formal algorithm by a programming language manual. For More Visit : KtuQbank.com | Fair Use Policy
  • 21. Algorithm ā€¢ So, there are several steps to reach a program from a mathematical model. ā€¢ In every step, there is a refinement(or conversion). ā€¢ That is to covert an informal algorithm to a program, we must go through several stages ā€¢ Three steps in refinement process: For More Visit : KtuQbank.com | Fair Use Policy
  • 22. Algorithm ā€¢ In the first stage, modeling, we try to represent the problem using an appropriate mathematical model such as a graph, tree etc. ā€¢ At this stage, the solution to the problem is an algorithm expressed very informally. ā€¢ During next stage, the algorithm is written in pseudo-language (or formal algorithm) which is a mixture of programming language constructs and less formal English statements. ā€¢ Here the operations to be performed on the various types of data become fixed. ā€¢ In the final stage, we choose an implementation and write the procedures for the various operations on that type. The remaining informal statements in the algorithm are replaced by C/C++ codes. For More Visit : KtuQbank.com | Fair Use Policy
  • 23. Analysis of algorithms ā€¢ After designing an algorithm, it has to be checked and its correctness needs to be predicted. ā€¢ This is done by analyzing the algorithm. ā€¢ An algorithm is analyzed with reference to the following: ā€¢ Correctness ā€¢ Execution time ā€¢ Amount of memory used ā€¢ Simplicity and clarity For More Visit : KtuQbank.com | Fair Use Policy
  • 24. Analysis of algorithms ā€¢ Algorithm Analysis Efficiency of an algorithm can be analyzed at two different stages, before implementation and after implementation, as mentioned below ā€¢ A priori analysis ā€¢ A posterior analysis For More Visit : KtuQbank.com | Fair Use Policy
  • 25. Algorithm Complexity ļƒ˜Efficiency of algorithms ļƒ˜Algorithm complexity is a measure which evaluates the order of the count of operations, performed by a given or algorithm as a function of the size of the input data. ļƒ˜Complexity is a rough approximation of the number of steps necessary to execute an algorithm. 1) Space complexity 2) Time complexity For More Visit : KtuQbank.com | Fair Use Policy
  • 26. ā€¢ Complexity can be constant, logarithmic, linear, n*log(n), quadrat ic, cubic, exponential, etc. For More Visit : KtuQbank.com | Fair Use Policy
  • 27. Analysis of algorithms ā€¢ Best case, worst case and average case of an algorithm ā€¢ The best case implies minimum execution time that the algorithm would demand. ā€¢ The worst case implies maximum execution time. ā€¢ The average case indicates the behavior of the algorithm in an average situation. For More Visit : KtuQbank.com | Fair Use Policy
  • 28. Asymptotic complexity ā€¢ Complexity of an algorithm is usually a function of n. ā€¢ Behavior of this function is usually expressed in terms of one or more standard functions. ā€¢ Expressing the complexity function with reference to other known functions is called asymptotic complexity. ā€¢ Three basic notations are used to express the asymptotic complexity- Big- oh(O), Big-omega(Ī©), Theta(Īø) For More Visit : KtuQbank.com | Fair Use Policy
  • 29. ā€¢ Asymptotic notations are the mathematical notations used to describe the running time of an algorithm when the input tends towards a particular value or a limiting value. ā€¢ For example: In bubble sort, when the input array is already sorted, the time taken by the algorithm is linear i.e. the best case. ā€¢ But, when the input array is in reverse condition, the algorithm takes the maximum time (quadratic) to sort the elements i.e. the worst case. ā€¢ When the input array is neither sorted nor in reverse order, then it takes average time. These durations are denoted using asymptotic notations. ā€¢ There are mainly three asymptotic notations: Theta notation, Omega notation and Big-O notation. For More Visit : KtuQbank.com | Fair Use Policy
  • 30. Big oh (O) Notations ā€¢ Formal method of expressing the upper bound of an algorithmā€™s running time. ā€¢ i.e. it is a measure of longest amount of time it could possibly take for an algorithm to complete. ā€¢ It is used to represent the worst case complexity. Definition: ā€¢ For non negative functions f(n) and g(n), f(n)=O(g(n)) if there exist an integer n0 and a constant C>0 such that for all integers n>n0, f(n) ā‰¤ C. g(n) then ā€¢ f(n)=O(g(n)) implies the behavior of f(n) with reference to another function g(n) and it signifies that g(n) is the upper bound of f(n) 30 For More Visit : KtuQbank.com | Fair Use Policy
  • 31. Big oh (O) Notations Graphical representation It is represented mathematically as 0 ā‰¤ f (n) ā‰¤ C. g(n)) ā€¢ For all values of n to the right of n0, the value of f(n) is on or below C. g(n) 31 O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ā‰¤ f(n) ā‰¤ cg(n) for all n ā‰„ n0 } For More Visit : KtuQbank.com | Fair Use Policy
  • 32. Omega Notation (Ī©-notation) ā€¢ Omega notation represents the lower bound of the running time of an algorithm. ā€¢ Thus, it provides best case complexity of an algorithm. For More Visit : KtuQbank.com | Fair Use Policy
  • 33. Ī©(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ā‰¤ cg(n) ā‰¤ f(n) for all n ā‰„ n0 } The above expression can be described as a function f(n) belongs to the set Ī©(g(n)) if there exists a positive constant c such that it lies above cg(n), for sufficiently large n. For any value of n, the minimum time required by the algorithm is given by Omega Ī©(g(n)) For More Visit : KtuQbank.com | Fair Use Policy
  • 34. Theta Notation (Ī˜-notation) ā€¢ Theta notation encloses the function from above and below. Since it represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average case complexity of an algorithm. For More Visit : KtuQbank.com | Fair Use Policy
  • 35. Ī˜(g(n)) = { f(n): there exist positive constants c1, c2 and n0 such that 0 ā‰¤ c1g(n) ā‰¤ f(n) ā‰¤ c2g(n) for all n ā‰„ n0 } The above expression can be described as a function f(n) belongs to the set Ī˜(g(n)) if there exist positive constants c1 and c2 such that it can be sandwiched between c1g(n) and c2g(n), for sufficiently large n. For More Visit : KtuQbank.com | Fair Use Policy
  • 36. Complexity of an algorithm(evaluation of algorithm) ā€¢ The complexity of an algorithm is the function, which give the running time or storage space in terms of input size. ā€¢ Space Complexity: How much space an algorithm needs to complete its task. ā€¢ Time Complexity: Running time of a program as a function of input size. ā€¢ Analysis of algorithms is the determination of the amount of time and space resources required to execute it. For More Visit : KtuQbank.com | Fair Use Policy
  • 37. Space Complexity ļƒ˜Space complexity = The amount of memory required by an algorithm to run to completion ā€¢ Two part : 1. Fixed part: independent of Input & output characteristics: ļƒ¼Instruction space ļƒ¼space for variables ļƒ¼space for constants & so on 2. Variable part: Space needed by variables, whose size is dependent on the size of the problem: ļƒ¼Space needed by referenced variables, ļƒ¼recursion stack space,etc L1.37 For More Visit : KtuQbank.com | Fair Use Policy
  • 38. Calculation S(p)=C+Sp ļƒ˜Let p be the algorithm ļƒ˜S(p) :space complexity ļƒ˜C:fixed space ļƒ˜ Sp:variable space L1.38 For More Visit : KtuQbank.com | Fair Use Policy
  • 39. Example 1 void main() { int x,y,z,sum; printf(ā€œenter 3 numbersā€); scanf(ā€œ%d%d%dā€,&x,&y,&z); Sum=x+y+z; Printf(ā€œ%dā€,sum); } ā€¢ Variables used are: ā€¢ Variable x: 1 word ā€¢ Variable y: 1 word ā€¢ Variable z: 1 word ā€¢ Variable sum: 1 word ā€¢ Total space:4 word For More Visit : KtuQbank.com | Fair Use Policy
  • 40. Example 2 Algoritm Sum(a,n) { S=0; for i=1 to n S=s+a[i]; Return s; } ā€¢ Size variable n:1 word ā€¢ Loop variable i:1 word ā€¢ Sum variable s:1 word ā€¢ Array a values: n words ā€¢ Total space:n+3 words L1.40 For More Visit : KtuQbank.com | Fair Use Policy
  • 41. Example 3 int main() { int a = 5,b = 5,c; c = a + b; printf("%d", c); } For More Visit : KtuQbank.com | Fair Use Policy
  • 42. Example 4 Algoritm Sum(a,n) { S=0; for i=1 to n for j=1 to m S=s+a[i][j]; } ā€¢ Size variable n:1 word ā€¢ Loop variable i:1 word ā€¢ Sum variable s:1 word ā€¢ Array a values: n*m words ā€¢ Total space:nm+3 words L1.42 For More Visit : KtuQbank.com | Fair Use Policy
  • 43. Time complexity: ā€¢ How much time needed for the completion of a program 2 components: 1. Compile time :Does not depend on instance characteristics. 2. Run time:Dependent on particular problem instance ā€¢ Time complexity :T(P)=C+Tp ā€¢ T(p):time complexity of algorithm P ā€¢ C:Compile time ā€¢ Tp :run time L1.43 For More Visit : KtuQbank.com | Fair Use Policy
  • 44. Time Complexity: Frequency count ļƒ˜Time complexity can be calculated by counting the number of steps each statement in the program executes Eg: ā€¢ Comments-0 steps ā€¢ Assignment statement-1 step ā€¢ Condition statement-1 step ā€¢ Loop condition for ā€˜nā€™ times-(n+1) steps ā€¢ Body of loop-N steps L1.44 For More Visit : KtuQbank.com | Fair Use Policy
  • 45. Frequency count ā€¢ Frequency count is, the number of times the statement is executed in the program. ā€¢ Letā€™s consider some of the program segments ā€¢ Program Segment A: ā€¦ x = x+2 ā€¦ For More Visit : KtuQbank.com | Fair Use Policy
  • 46. Frequency count ā€¢ Program Segment B: ā€¦ for k =1 to n do x = x+2 end ā€¦ ā€¢ Program Segment C: ā€¦ for j= 1 to n do for x = 1 to n do x = x+2 end end For More Visit : KtuQbank.com | Fair Use Policy
  • 47. Frequency count ā€¢ The frequency count of the statement in the program segment A is 1.(It gets executed once) ā€¢ In the program segment B, the frequency count of the statement is n, since the for loop in which the statement is embedded executes n(n>=1) times. ā€¢ In the program segment C, the statement is executed n2(n>=1) times, since the statement is embedded in a nested for loop, executing n times each. For More Visit : KtuQbank.com | Fair Use Policy
  • 48. Example 1 Void hello() { for(i=1; i <=n; i++) ļƒ n+1 times { print(ā€Helloā€; ); ļƒ n times } } ā€¢ Add all statement:n+1+n=2n+1 times For More Visit : KtuQbank.com | Fair Use Policy
  • 49. Example 2 float sum(float a[ ], int n) { float temp = 0; ļƒ 1 times int i; for(i=0; i <n; i++) ļƒ n+1 times { temp=temp+a[i]; ļƒ  n times } return (temp); ļƒ 1 times } Total time: 2n+3 times For More Visit : KtuQbank.com | Fair Use Policy
  • 50. Example 3 Void add () { int i, j,m,n,a[]; for (i = 0; i < n; i++) ļƒ n+1 times for (j=0; j< m; j++) ļƒ n(m+1) times s=s+a[i][j]; ļƒ n*m times } Total:n+1+nm+n+nm=2nm+2n+1 For More Visit : KtuQbank.com | Fair Use Policy
  • 51. Different programming methodologies ā€¢ Deals with different methods of designing programs. ā€¢ Modular programming: ā€¢ Procedural programming ā€¢ The focus is entirely on writing code(functions) ā€¢ Data is passive ā€¢ Any code may access the contents of any data structure passed to it- i.e. no encapsulation. ā€¢ Here programs are written as functions ā€¢ Minimal interaction between functions. ā€¢ Easy to detect error and to test it in isolation ā€¢ It discourages the use of control variables and flags in parameters. ā€¢ It encourages splitting the functionality into two types ā€¢ Master and slave ā€¢ Two methods Modular programming: ā€¢ Top-Down and Bottom-Up For More Visit : KtuQbank.com | Fair Use Policy
  • 52. Types of Programming Methodologies 1. Procedural Oriented Programming 2. Object-Oriented Programming 3. Structured Programming 4. Modular Programming For More Visit : KtuQbank.com | Fair Use Policy
  • 53. 1)PROCEDURAL ORIENTED PROGRAMMING 2)OBJECT ORIENTED PROGRAMMING In procedural programming, program is divided into small parts called functions. In object oriented programming, program is divided into small parts called objects. Procedural programming follows top down approach. Object oriented programming follows bottom up approach. There is no access specifier in procedural programming. Object oriented programming have access specifiers like private, public, protected etc. Adding new data and function is not easy. Adding new data and function is easy. Procedural programming does not have any proper way for hiding data so it is less secure. Object oriented programming provides data hiding so it is more secure. In procedural programming, overloading is not possible. Overloading is possible in object oriented programming. In procedural programming, function is more important than data. In object oriented programming, data is more important than function. Procedural programming is based on unreal world. Object oriented programming is based on real world. Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python, C# etc. For More Visit : KtuQbank.com | Fair Use Policy
  • 54. Different programming methodologies 3)Modular programming: ā€¢ Procedural programming ā€¢ The focus is entirely on writing code(functions) ā€¢ Data is passive ā€¢ No data encapsulation. ā€¢ Here programs are written as functions ā€¢ Minimal interaction between functions. ā€¢ Easy to detect error and to test it in isolation ā€¢ Two methods Modular programming: a) Top-Down approach b) Bottom-Up approach For More Visit : KtuQbank.com | Fair Use Policy
  • 55. Modular programming: a)Top-Down design: ā€¢ Here a program should be divided into a main module and its related modules. ā€¢ Each module should also be divided into sub modules according to programming style. ā€¢ The division process continues, until the module consists only of elementary process that are understood and cannot be further subdivided. ā€¢ Here modules are arranged in a hierarchical manner. ā€¢ Here each module have single entry and single exit point. ā€¢ In C, It is done using function. For More Visit : KtuQbank.com | Fair Use Policy
  • 56. Modular programming: ā€¢ Top-Down algorithm design: For More Visit : KtuQbank.com | Fair Use Policy
  • 57. Modular programming: ā€¢ Bottom-up algorithm design: ā€¢ Opposite of top-down design. ā€¢ Starting the design with specific modules and build them into more complex structures, ending at the top. ā€¢ Widely used in testing. ā€¢ Here lowest level functions are written and tested first. ā€¢ This process continues, moving up the level, until the main function is tested. For More Visit : KtuQbank.com | Fair Use Policy
  • 58. S.NO. TOP DOWN APPROACH BOTTOM UP APPROACH 1. In this approach We focus on breaking up the problem into smaller parts. In bottom up approach, we solve smaller problems and integrate it as whole and complete the solution. 2. Mainly used by structured programming language such as COBOL, Fortan, C etc. Mainly used by object oriented programming language such as C++, C#, Python. 3. Each part is programmed separately therefore contain redundancy. Redundancy is minimized by using data encapsulation and data hiding. 4. In this the communications is less among modules. In this module must have communication. 5. It is used in debugging, module documentation, etc. It is basically used in testing. 6. In top down approach, decomposition takes place. In bottom up approach composition takes place. 7. In this top function of system might be hard to identify. In this sometimes we can not build a program from the piece we have started. 8. In this implementation details may differ. This is not natural for people to assemble. For More Visit : KtuQbank.com | Fair Use Policy
  • 59. For More Visit : KtuQbank.com | Fair Use Policy
  • 60. Programming methodologies ā€¢ Structured programming: ā€¢ It is a Programming style. ā€¢ Not programming with structures, but by using following types of codes structures to write programs: ā€¢ 1. Sequence of sequentially executed statements. ā€¢ 2. Conditional execution of statements(i.e. ā€œifā€ statements) ā€¢ 3. Looping or iteration(i.e. ā€œfor, doā€¦while and whileā€ stmts) ā€¢ 4. Structured subroutine calls(i.e. functions) For More Visit : KtuQbank.com | Fair Use Policy
  • 61. ā€¢ Structured programming: ā€¢ Here, the following language usage is forbidden(not allowed) ā€¢ 1. GoTo statements ā€¢ ā€œBreakā€ or ā€œContinueā€ out of the middle of loops ā€¢ Multiple exit points or multiple ā€œreturnā€ statements to a function/ procedure/subroutine ā€¢ Multiple entry points to a function/ procedure/subroutine ā€¢ In structured programming, there is a great risk that the implementation details of many data structures have to be shared between functions and thus globally exposed. ā€¢ This tempts other functions to use there implementation details, there by creating unwanted dependencies between different parts of the program. For More Visit : KtuQbank.com | Fair Use Policy
  • 62. ā€¢ Structured programming: ā€¢ The main disadvantage is that all decisions made from the start of the project depends directly or indirectly on the high-level specification of the application. ā€¢ This specification tends to change over time. ā€¢ So, there is a great risk that, large part of the application need to be rewritten. For More Visit : KtuQbank.com | Fair Use Policy
  • 63. For More Visit : KtuQbank.com | Fair Use Policy
  • 64. For More Visit : KtuQbank.com | Fair Use Policy
  • 65. THANK YOU For More Visit : KtuQbank.com | Fair Use Policy