Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Design & Analysis of Algorithm

CS-503
Growth of a Function In Analysis Of Algorithm

WHAT IS THE GOAL OF ANALYSIS OF ALGORITHM?


• It is an important aspect that we need to consider that why we analyze
algorithms.
Goals of Analysis of Algorithm

• To compare algorithms mainly in terms of running time but also in terms of


other factors like memory requirements, programmers efforts etc.
• Space and time complexity plays a very important role in analysis of
algorithm.
• When running time of algorithm increases the size of problem also increases.
Types of Analysis of Algorithm

There are three types of analysis of algorithm:


1. Worst Case Analysis
2. Best Case Analysis
3. Average Case Analysis
Worst Case Analysis

• It provides an upper bound on running time that means it takes a large amount
of time for any input data to run and gives us required output.

• An absolute guarantee that the algorithm would not run longer, no matter what
the inputs are, it is continuously work in vigorous manner but will not gives us
required output.
Best Case Analysis

• It provides a lower bound on the running time that means it take minimum
time required for gives us desired output.
• Input is the one for which the algorithm runs the fastest is the best case for
analysis of algorithm
• Lower bound <= Running Time <= Upper bound
Average Case Analysis

• It provides prediction about running time.


• It lies between worst case and best case scenario.
• We take a random input we get an Random output.
• So, it lies between upper and lower bound.
Analysis Functions

• Running time is expressed as a function of the input size n as f(n).


• The various functions are compared with respect to running time.
• These analysis are independent of machine time and programming style.
Cost Analysis for Simple Code

Code Structure Steps Cost Analysis


sum=0; C1 C1
for(i=0; i<N; i++) C2 C2 * (N+1)
for(j=0; j<N; j++) C3 C2 * N * (N+1)
sum+= arr [i][j] C4 C 3 * N2
Cost Analysis for Simple Code

• So, the total cost analysis for simple code is:

C1+ C2 * (N+1)+ C2* N * (N+1)+ C3 * N2


Flow Chart

• A FLOWCHART IS SIMPLY A GRAPHICAL REPRESENTATION OF STEPS.


• IT SHOWS STEPS IN SEQUENTIAL ORDER AND IS WIDELY USED IN
PRESENTING THE FLOW OF ALGORITHMS, WORKFLOW OR
PROCESSES.
• TYPICALLY, A FLOWCHART SHOWS THE STEPS AS BOXES OF
VARIOUS KINDS, AND THEIR ORDER BY CONNECTING THEM WITH
ARROWS.
Flow Chart Symbols
• TERMINATOR: THE TERMINATOR SYMBOL REPRESENTS THE STARTING OR
ENDING POINT OF THE SYSTEM. PROCESS.

• A BOX INDICATES SOME PARTICULAR OPERATION


Flow Chart Symbols

• DECISION: A DIAMOND REPRESENTS A DECISION OR BRANCHING POINT.


LINES COMING OUT FROM THE DIAMOND INDICATES DIFFERENT POSSIBLE
SITUATIONS, LEADING TO DIFFERENT SUB-PROCESSES.

• DATA: IT REPRESENTS INFORMATION ENTERING OR LEAVING THE SYSTEM.


AN INPUT MIGHT BE AN ORDER FROM A CUSTOMER. OUTPUT CAN BE A
PRODUCT TO BE DELIVERED.
Flow Chart Symbols

• FLOW: LINES REPRESENT THE FLOW OF THE SEQUENCE AND DIRECTION OF


A PROCESS.

• DELAY OR BOTTLENECK: IDENTIFIES A DELAY OR A BOTTLENECK.


Flow Chart Example: Simple Algorithm

• A FLOWCHART CAN ALSO BE USED IN VISUALIZING


ALGORITHMS, REGARDLESS OF ITS COMPLEXITY.
• HERE IS AN EXAMPLE THAT SHOWS HOW FLOWCHART CAN BE
USED IN SHOWING A SIMPLE SUMMATION PROCESS.
Flow Chart Example: Medical Service

• THIS IS A HOSPITAL FLOWCHART EXAMPLE THAT SHOWS HOW


CLINICAL CASES SHALL BE PROCESSED.
• THIS FLOWCHART USES DECISION SHAPES INTENSIVELY IN
REPRESENTING ALTERNATIVE FLOWS.

You might also like