SlideShare a Scribd company logo
Bismillah-e-Rahman-e-Raheem
COMPLEXITY OF
ALGORITHM AND
COST_TIME TRADE OFF
Muhammad Muzammal
E-Mail: hello-hi99@hotmail.com
By
Introduction
Algorithm
An algorithm is a finite set of well-defined instructions
for accomplishing some task, which given an initial
state, will terminate in a defined end-state.
Complexity of algorithms
Complexity of algorithms
The complexity of an algorithm is a function f (n) which measures
the time and space used by an algorithm in terms of input size n.
In computer science, the complexity of an algorithm is a way
to classify how efficient an algorithm is, compared to alternative
ones. The focus is on how execution time increases with the data
set to be processed.
The computational complexity and efficient implementation of the
algorithm are important in computing, and this depends on
suitable data structures.
Complexity of algorithms
Description of Complexity
Different algorithms may complete the same task with
a different set of instructions in less or more time,
space or effort than other. The analysis and study of
algorithms is a discipline in Computer Science which
has a strong mathematical background. It often relies
on theoretical analysis of pseudo-code. To compare
the efficiency of algorithms, we don't rely on abstract
measures such as the time difference in running
speed, since it too heavily relies on the processor
power and other tasks running in parallel.
Classes of complexity
Polynomial time algorithms
•(C) --- Constant time --- the time necessary to perform
the algorithm does not change in response to the size of
the problem.
•(n) --- Linear time --- the time grows linearly with the size
(n) of the problem.
• (n2) --- Quadratic time --- the time grows quadratically
with the size (n) of the problem
Classes of complexity
Sub-linear time algorithms
• It grow slower than linear time algorithms
• Super-polynomial time algorithms
• It grows faster than polynomial time algorithms.
• Exponential time --- the time required grows
exponentially with the size of the problem.
Example of finding the complexity of an
algorithm
BUBBLE SORT
For ( int I = 0 ; I < 5 ; I ++ )
For ( int j = 0 ; j < 4 ; j ++ )
If (A [ j ] > A [ j + 1 ] ) {
Temp = A [ j ] ;
A [ j ] = A [ j+1 ] ;
A [ j + 1 ] =Temp;
}
Complexity of Bubble Sort
The time for assorting algorithm is measured in the
number of the comparisons. The number of f(n) of
comparisons in the bubble sort is easily computed.
Specifically ,there are n-1 comparisons during the 1st
pass , which places the largest element in the last
position ; there are n-2 comparisons in the 2nd step,
which places the 2nd largest element in the next –to-
last position; and so on.. In other words, the time
required to execute the bubble sort algorithm is
proportional to n2, where n is the number of input
items.
Example of finding the complexity of an
algorithm
Linear Search
Int array[10]={10,20,30,40,50,60,70,80,90,100};
Int I,n, Loc=-1;
Cout<<“Enter the value to find “;
Cin>>n;
For(i=0;I<10;I++)
if(array[I]==n)
Loc=I;
If(Loc==-1)
Cout<<“Value not found”;
Else
Cout<<“The value”<<n<<“is found at index “<<Loc;
Space-time tradeoff
In computer science, a space-time tradeoff refers to a
choice between algorithmic solutions of a data
processing problem that allows one to derease the
running time of an algorithmic solution by increasing
the space to store the data and vice versa.
The computation time can be reduced at the cost of
increased memory use. As the relative costs of CPU
cycles, RAM space, and hard drive space change —
hard drive space has for some time been getting
cheaper at a much faster rate than other components
of computers, the appropriate choices for space-time
tradeoffs have changed radically. Often, by exploiting
a space-time tradeoff, a program can be made to run
much faster.
Space-time tradeoff
A space-time tradeoff can be applied to the
problem of data storage. If data is stored
uncompressed, it takes more space but less time
than if the data were stored compressed (since
compressing the data reduces the amount of
space it takes, but it takes time to run the
compression algorithm). Depending on the
particular instance of the problem, either way is
practical.
Continued…
Larger code size can be traded for higher program
speed when applying loop unwinding. This technique
makes the code longer for each iteration of a loop, but
saves the computation time required for jumping back to
the beginning of the loop at the end of each iteration.
Algorithms that make use of space-time tradeoffs to
achieve better running times include the baby-step
giant-step algorithm for calculating discrete logarithms
Using Genetic Algorithms to Solve
Construction Time-Cost Trade-Off Problems
Existing methods for time-cost trade-off analysis focus
on using heuristics or mathematical programming.
These methods, however, are not efficient enough to
solve large-scale CPM networks (hundreds of activities
or more). Analogous to natural selection and genetics in
reproduction, genetic algorithms (GAs) have been
science and
successfully
engineering
adopted to solve many
problems and have proven to be an
efficient means for searching optimal solutions in a
large problem domain computer program that can
execute the algorithm efficiently.

More Related Content

PPTX
algocomplexity cost effective tradeoff in
javed75
 
PPT
Complexity of Algorithm
Muhammad Muzammal
 
PPTX
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
PPTX
TimeComplexity important topic of Algorithm analysis .pptx
haiderkhooradnan
 
PPT
CSCI 4140-AA Lec_02.ppt
ZahidKhan671907
 
PPTX
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
ryadavrohit26
 
DOCX
Ds
Mohit Saini
 
PPTX
Analysis of Algorithm full version 2024.pptx
rajesshs31r
 
algocomplexity cost effective tradeoff in
javed75
 
Complexity of Algorithm
Muhammad Muzammal
 
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
Tanya Makkar
 
TimeComplexity important topic of Algorithm analysis .pptx
haiderkhooradnan
 
CSCI 4140-AA Lec_02.ppt
ZahidKhan671907
 
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
ryadavrohit26
 
Analysis of Algorithm full version 2024.pptx
rajesshs31r
 

Similar to presentationfinal-090714235255-phpapp01 (1) (2).pptx (20)

PPTX
Design Analysis of Alogorithm 1 ppt 2024.pptx
rajesshs31r
 
PDF
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
PDF
Analysis of Algorithms
Amna Saeed
 
PPTX
L1_Start_of_Learning_of_Algorithms_Basics.pptx
3cL1Ps3FTMS
 
PPTX
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
PPTX
Data structure introduction
NavneetSandhu0
 
PPTX
L1_DatabAlgorithm Basics with Design & Analysis.pptx
dpdiyakhan
 
PPTX
Introduction to Algorithms, Steps, Complexity
berggold2024
 
PPTX
Design & Analysis of Algorithm course .pptx
JeevaMCSEKIOT
 
DOCX
Time Complexity Analysis in Data Structure.docx
Mani .S (Specialization in Semantic Web)
 
PPTX
Algorithm analysis (All in one)
jehan1987
 
PDF
Algorithm Design and Analysis
Sayed Chhattan Shah
 
PPTX
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
PPS
Data Structures and Algorithms Unit 01
Prashanth Shivakumar
 
PPTX
Mastering Algorithms: Time and Space Complexity in Algorithms
Anusha10399
 
PPTX
ADSA orientation.pptx
Kiran Babar
 
PPTX
Segment_1_New computer algorithm for cse.pptx
fahmidasetu
 
PPTX
Searching Algorithms
Afaq Mansoor Khan
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
rajesshs31r
 
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
Analysis of Algorithms
Amna Saeed
 
L1_Start_of_Learning_of_Algorithms_Basics.pptx
3cL1Ps3FTMS
 
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
Data structure introduction
NavneetSandhu0
 
L1_DatabAlgorithm Basics with Design & Analysis.pptx
dpdiyakhan
 
Introduction to Algorithms, Steps, Complexity
berggold2024
 
Design & Analysis of Algorithm course .pptx
JeevaMCSEKIOT
 
Time Complexity Analysis in Data Structure.docx
Mani .S (Specialization in Semantic Web)
 
Algorithm analysis (All in one)
jehan1987
 
Algorithm Design and Analysis
Sayed Chhattan Shah
 
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Data Structures and Algorithms Unit 01
Prashanth Shivakumar
 
Mastering Algorithms: Time and Space Complexity in Algorithms
Anusha10399
 
ADSA orientation.pptx
Kiran Babar
 
Segment_1_New computer algorithm for cse.pptx
fahmidasetu
 
Searching Algorithms
Afaq Mansoor Khan
 
Ad

More from javed75 (10)

PPTX
Unit-1.pptx final unit new mtech unit thre
javed75
 
PPT
javed_prethesis2608 on predcition of heart disease
javed75
 
PPT
Section 7.5 version 2 AM new ppt for every
javed75
 
PPTX
Cyber_Security_Awareness_Presentation (1).pptx
javed75
 
PPTX
anand ethics ppt for phd scholar integral
javed75
 
PPTX
Data Science.pptx NEW COURICUUMN IN DATA
javed75
 
PPT
1 Basic E-Commerce Concepts for it 2ndt year
javed75
 
PPT
UNIT-IV WT web technology for 1st year cs
javed75
 
PPTX
training about android installation and usa
javed75
 
PPTX
Phd2023-2024cIntegralUniversitynida.pptx
javed75
 
Unit-1.pptx final unit new mtech unit thre
javed75
 
javed_prethesis2608 on predcition of heart disease
javed75
 
Section 7.5 version 2 AM new ppt for every
javed75
 
Cyber_Security_Awareness_Presentation (1).pptx
javed75
 
anand ethics ppt for phd scholar integral
javed75
 
Data Science.pptx NEW COURICUUMN IN DATA
javed75
 
1 Basic E-Commerce Concepts for it 2ndt year
javed75
 
UNIT-IV WT web technology for 1st year cs
javed75
 
training about android installation and usa
javed75
 
Phd2023-2024cIntegralUniversitynida.pptx
javed75
 
Ad

Recently uploaded (20)

DOCX
RUHS II MBBS Pharmacology Paper-I with Answer Key | 26 July 2025 (New Scheme)
Shivankan Kakkar
 
PPTX
Anatomy of eyelids basic anatomy covered along with abnormalities of eyelids
SummyBhatnagar1
 
PPT
8-Ergonomics of Aging.ppt · version 1.ppt
Bolan University of Medical and Health Sciences ,Quetta
 
PPTX
Chemical Burn, Etiology, Types and Management.pptx
Dr. Junaid Khurshid
 
PPTX
Anaesthesia Machine - Safety Features and Recent Advances - Dr.Vaidyanathan R
VAIDYANATHAN R
 
PPTX
Pharmacology is the scientific study of how drugs and other chemical substanc...
tarun35435605
 
PPTX
CEPHALOPELVIC DISPROPORTION (Mufeez).pptx
mufeezwanim2
 
PPTX
12. Biomechanicsof the humanlowerextremity.pptx
Bolan University of Medical and Health Sciences ,Quetta
 
DOCX
Paediatrics Question Papers – III MBBS (Part II), RUHS Main Exam 2025-2016
Shivankan Kakkar
 
PPTX
HALITOSIS presentation for Ear, Nose and throat.pptx
stefanumerah1
 
PDF
Bassem Matta, CCMA
Smiling Lungs
 
PDF
Histology of Nose & paranasal sinuses - Dr Muhammad Ali Rabbani
MedicoseAcademics
 
PPTX
Optimal sites for mini-implant insertion into the infrazygomatic crest accord...
Dr Anurag JB
 
PPT
9. Applied Biomechanics (fracture fixation)etc.ppt
Bolan University of Medical and Health Sciences ,Quetta
 
PPTX
13.Anesthesia and its all types.....pptx
Bolan University of Medical and Health Sciences ,Quetta
 
PPTX
BRAIN DEATH- DIAGNOSIS, MANAGEMENT AND LEGAL ISSUES - Dr. Vaidyanathan R .pptx
Dr.Vaidyanathan R
 
PPTX
The Anatomy of the Major Salivary Glands
Srinjoy Chatterjee
 
DOCX
RUHS II MBBS Pharmacology Paper-II with Answer Key | 28 July 2025 (New Scheme)
Shivankan Kakkar
 
PPTX
TOC sampling methods for cleaning validation
Markus Janssen
 
PDF
Writing and Teaching as Personal Documentation of Continuing Professional Dev...
Robertus Arian Datusanantyo
 
RUHS II MBBS Pharmacology Paper-I with Answer Key | 26 July 2025 (New Scheme)
Shivankan Kakkar
 
Anatomy of eyelids basic anatomy covered along with abnormalities of eyelids
SummyBhatnagar1
 
8-Ergonomics of Aging.ppt · version 1.ppt
Bolan University of Medical and Health Sciences ,Quetta
 
Chemical Burn, Etiology, Types and Management.pptx
Dr. Junaid Khurshid
 
Anaesthesia Machine - Safety Features and Recent Advances - Dr.Vaidyanathan R
VAIDYANATHAN R
 
Pharmacology is the scientific study of how drugs and other chemical substanc...
tarun35435605
 
CEPHALOPELVIC DISPROPORTION (Mufeez).pptx
mufeezwanim2
 
12. Biomechanicsof the humanlowerextremity.pptx
Bolan University of Medical and Health Sciences ,Quetta
 
Paediatrics Question Papers – III MBBS (Part II), RUHS Main Exam 2025-2016
Shivankan Kakkar
 
HALITOSIS presentation for Ear, Nose and throat.pptx
stefanumerah1
 
Bassem Matta, CCMA
Smiling Lungs
 
Histology of Nose & paranasal sinuses - Dr Muhammad Ali Rabbani
MedicoseAcademics
 
Optimal sites for mini-implant insertion into the infrazygomatic crest accord...
Dr Anurag JB
 
9. Applied Biomechanics (fracture fixation)etc.ppt
Bolan University of Medical and Health Sciences ,Quetta
 
13.Anesthesia and its all types.....pptx
Bolan University of Medical and Health Sciences ,Quetta
 
BRAIN DEATH- DIAGNOSIS, MANAGEMENT AND LEGAL ISSUES - Dr. Vaidyanathan R .pptx
Dr.Vaidyanathan R
 
The Anatomy of the Major Salivary Glands
Srinjoy Chatterjee
 
RUHS II MBBS Pharmacology Paper-II with Answer Key | 28 July 2025 (New Scheme)
Shivankan Kakkar
 
TOC sampling methods for cleaning validation
Markus Janssen
 
Writing and Teaching as Personal Documentation of Continuing Professional Dev...
Robertus Arian Datusanantyo
 

presentationfinal-090714235255-phpapp01 (1) (2).pptx

  • 3. Introduction Algorithm An algorithm is a finite set of well-defined instructions for accomplishing some task, which given an initial state, will terminate in a defined end-state.
  • 4. Complexity of algorithms Complexity of algorithms The complexity of an algorithm is a function f (n) which measures the time and space used by an algorithm in terms of input size n. In computer science, the complexity of an algorithm is a way to classify how efficient an algorithm is, compared to alternative ones. The focus is on how execution time increases with the data set to be processed. The computational complexity and efficient implementation of the algorithm are important in computing, and this depends on suitable data structures.
  • 5. Complexity of algorithms Description of Complexity Different algorithms may complete the same task with a different set of instructions in less or more time, space or effort than other. The analysis and study of algorithms is a discipline in Computer Science which has a strong mathematical background. It often relies on theoretical analysis of pseudo-code. To compare the efficiency of algorithms, we don't rely on abstract measures such as the time difference in running speed, since it too heavily relies on the processor power and other tasks running in parallel.
  • 6. Classes of complexity Polynomial time algorithms •(C) --- Constant time --- the time necessary to perform the algorithm does not change in response to the size of the problem. •(n) --- Linear time --- the time grows linearly with the size (n) of the problem. • (n2) --- Quadratic time --- the time grows quadratically with the size (n) of the problem
  • 7. Classes of complexity Sub-linear time algorithms • It grow slower than linear time algorithms • Super-polynomial time algorithms • It grows faster than polynomial time algorithms. • Exponential time --- the time required grows exponentially with the size of the problem.
  • 8. Example of finding the complexity of an algorithm BUBBLE SORT For ( int I = 0 ; I < 5 ; I ++ ) For ( int j = 0 ; j < 4 ; j ++ ) If (A [ j ] > A [ j + 1 ] ) { Temp = A [ j ] ; A [ j ] = A [ j+1 ] ; A [ j + 1 ] =Temp; }
  • 9. Complexity of Bubble Sort The time for assorting algorithm is measured in the number of the comparisons. The number of f(n) of comparisons in the bubble sort is easily computed. Specifically ,there are n-1 comparisons during the 1st pass , which places the largest element in the last position ; there are n-2 comparisons in the 2nd step, which places the 2nd largest element in the next –to- last position; and so on.. In other words, the time required to execute the bubble sort algorithm is proportional to n2, where n is the number of input items.
  • 10. Example of finding the complexity of an algorithm Linear Search Int array[10]={10,20,30,40,50,60,70,80,90,100}; Int I,n, Loc=-1; Cout<<“Enter the value to find “; Cin>>n; For(i=0;I<10;I++) if(array[I]==n) Loc=I; If(Loc==-1) Cout<<“Value not found”; Else Cout<<“The value”<<n<<“is found at index “<<Loc;
  • 11. Space-time tradeoff In computer science, a space-time tradeoff refers to a choice between algorithmic solutions of a data processing problem that allows one to derease the running time of an algorithmic solution by increasing the space to store the data and vice versa. The computation time can be reduced at the cost of increased memory use. As the relative costs of CPU cycles, RAM space, and hard drive space change — hard drive space has for some time been getting cheaper at a much faster rate than other components of computers, the appropriate choices for space-time tradeoffs have changed radically. Often, by exploiting a space-time tradeoff, a program can be made to run much faster.
  • 12. Space-time tradeoff A space-time tradeoff can be applied to the problem of data storage. If data is stored uncompressed, it takes more space but less time than if the data were stored compressed (since compressing the data reduces the amount of space it takes, but it takes time to run the compression algorithm). Depending on the particular instance of the problem, either way is practical.
  • 13. Continued… Larger code size can be traded for higher program speed when applying loop unwinding. This technique makes the code longer for each iteration of a loop, but saves the computation time required for jumping back to the beginning of the loop at the end of each iteration. Algorithms that make use of space-time tradeoffs to achieve better running times include the baby-step giant-step algorithm for calculating discrete logarithms
  • 14. Using Genetic Algorithms to Solve Construction Time-Cost Trade-Off Problems Existing methods for time-cost trade-off analysis focus on using heuristics or mathematical programming. These methods, however, are not efficient enough to solve large-scale CPM networks (hundreds of activities or more). Analogous to natural selection and genetics in reproduction, genetic algorithms (GAs) have been science and successfully engineering adopted to solve many problems and have proven to be an efficient means for searching optimal solutions in a large problem domain computer program that can execute the algorithm efficiently.