SlideShare a Scribd company logo
ALGORITHM



www.eshikshak.
Introduction to Algorithm
● An algorithm is finite set of steps defining the
  solution of a particular problem.
● It can be expressed in English like language,
  called pseudocode, in programming language
  or in the form of flowchart.




               www.eshikshak.co.in
Characteristics
● Input – There are zero or more values which are
  externally supplied.
● Output – At least one value is produced
● Definiteness – Each step must be clear and
  unambiguous
● Finiteness – If we trace the steps of an
  algorithm, then for all cases, the algorithm must
  terminate after a finite number of steps
● Effectiveness – Each step must be sufficiently
  basic that it can in principal be carried out by a
  person using only paper and pencil
                www.eshikshak.co.in
Algorithm Complexity
● There are basically two aspects of computer
  programming.
  ○ Data Organization (i.e Data & structure)
  ○ Algorithm
● The choice of a particular algorithm depends
  on the following consideration :
  ○ Time Complexity (Performance Requirements)
  ○ Space Complexity (Memory Requirements)



               www.eshikshak.co.in
Space Complexity
● It means the amount of memory, algorithm or
  program needs to run to completion.

● Some of the reasons for studying space
  complexity are
  ○ If a multi user system
  ○ Sufficient memory is available to run the
    program



               www.eshikshak.co.in
Space Complexity (Cont.)
● The space needed by a program consists of
  the following components.
  ○ Instruction Space : Space needed to store the
    executable version of the program
  ○ Data Space : Space needed to store all
    constants, variable values and has further
    following components
     ■ Constants, variables, structured variables like
       array and structure
     ■ Dynamically allocated space


                www.eshikshak.co.in
Space Complexity (Cont.)
● Environmental Stack Space : Space needed
  to store the information needed to resume the
  suspended functions.
  ○ Return Address
  ○ Values of all local variables and the values of
    formal parameters in the function being
    involved.




               www.eshikshak.co.in
Time Complexity
● It means the amount of time it needs to run to
  completion
● Reasons for studying time complexity
  ○ Interested to know in advance that whether a
    program will provide a satisfactory real time
    response
  ○ There may be several possible solutions with
    different time requirements



               www.eshikshak.co.in
Expressing Space and Time
Complexity
● The space and/or time complexity is usually
  expressed in form of the function f(n)
   ○ Where n is the input size for a given instance of the
     problem being solved.
● Expressing space and/ or time complexity as a
  function has following reasons
   ○ We may be interested to predict the rate of growth
     of complexity as the size of problem increases.
   ○ To Compare the complexities of two or more
     algorithm
   ○ Since in modern computers, the memory is not a
     sence constraint, therefore, our analysis of
                 www.eshikshak.co.in
     algorithms will be on the basis of time complexity.
Big ‘O’ Notation
● Big O is a characterization scheme that
  allows to measure properties of algorithms
  such time and space complexity.
● It is useful to set the prerequisites of
  algorithms and to develop and design efficient
  algorithms in terms of time and space
  complexity.




              www.eshikshak.co.in
Categories of Algorithm
● Based on Big O notation, the algorithm can
  be categorized as follows
  ○ Constant time O(1)
  ○ Logarithmic time O(log n)
  ○ Linear time O(n)
  ○ Polynomial time O(nk) (for k > 1)
  ○ Exponentail time O(kn) for k > 1




               www.eshikshak.co.in
Algorithm Analysis
● Different ways or algorithms to solve a
  problem.
● Hence, some of the algorithm may be more
  efficient than the others
● There are different types of time complexities
  which can be analyzed for an algorithm
   ○ Best Case Time Analysis
   ○ Average Case Time Analysis
   ○ Worst Case Time Analysis

               www.eshikshak.co.in
Best Case Time Complexity
● It is a measure of the minimum time that the
  algorithm will require for an input of size ‘n’.
● The running time of many algorithms varies
  not only for the inputs of different sizes but
  also for the different inputs of same size
   ○ Example : Sorting or Searching




                www.eshikshak.co.in
Worst Case Time Complexity
● The worst case time complexity of an
  algorithm is a measure of the maximum time
  that the algorithm will require for an input of
  size ‘n’.

● Example : If ‘n’ input data items are supplied in
  reverse order for any sorting algorithm, the
  algorithm will require n2 operations to perform the
  sort.


                www.eshikshak.co.in
Average Case Time Complexity
● The time that an algorithm will require to
  execute a typical input data of size ‘n’ is
  known as average case time complexity.




               www.eshikshak.co.in

More Related Content

PPT
Introduction to data structures and Algorithm
ODP
Parallel Programming In Java
PDF
[EMNLP2017読み会] Efficient Attention using a Fixed-Size Memory Representation
PPT
Analysis of algo
PPTX
Multi layered perceptron (mlp)
PPT
Al2ed chapter16
PPTX
Compiler in System Programming/Code Optimization techniques in System Program...
PPTX
Introduction to data structures and Algorithm
Parallel Programming In Java
[EMNLP2017読み会] Efficient Attention using a Fixed-Size Memory Representation
Analysis of algo
Multi layered perceptron (mlp)
Al2ed chapter16
Compiler in System Programming/Code Optimization techniques in System Program...

What's hot (6)

PPTX
Speeding Up Sub-Optimal MAPF Algorithms
PDF
Elementary Parallel Algorithms
PDF
Scalable precise-dynamic-datarace-detection-for-structured-parallelism
PPT
Chap12 slides
Speeding Up Sub-Optimal MAPF Algorithms
Elementary Parallel Algorithms
Scalable precise-dynamic-datarace-detection-for-structured-parallelism
Chap12 slides
Ad

Similar to Algorithm 110801105245-phpapp01-120223065724-phpapp02 (20)

PPTX
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
PPT
ALGORITHM-ANALYSIS.ppt
PPTX
Unit 1, ADA.pptx
PPTX
Analysis of Algorithms_Under Graduate Class Slide
PPTX
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
PDF
DSA
PDF
Analysis of Algorithms
PDF
Design & Analysis of Algorithms Lecture Notes
PDF
Algorithms.pdf
PDF
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
PPTX
Analysis of algorithn class 2
PPTX
Algorithm Introduction
PPTX
Design and Analysis of Algorithms.pptx
PPTX
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
PPTX
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
PPTX
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
PPT
Chapter 2 ds
PPTX
2. Introduction to Algorithm.pptx
PPTX
Chapter one Department Computer Science
Modile-1-PPT-1-BCAC0207-AlgorithmDesign.pptx
ALGORITHM-ANALYSIS.ppt
Unit 1, ADA.pptx
Analysis of Algorithms_Under Graduate Class Slide
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
DSA
Analysis of Algorithms
Design & Analysis of Algorithms Lecture Notes
Algorithms.pdf
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
Analysis of algorithn class 2
Algorithm Introduction
Design and Analysis of Algorithms.pptx
Module-1.pptxbdjdhcdbejdjhdbchchchchchjcjcjc
TIME EXECUTION OF DIFFERENT SORTED ALGORITHMS
BCSE202Lkkljkljkbbbnbnghghjghghghghghghghgh
Chapter 2 ds
2. Introduction to Algorithm.pptx
Chapter one Department Computer Science
Ad

More from dhruv patel (8)

DOCX
Coddrules 120309094848-phpapp02
DOCX
Coddrules 120309094807-phpapp01
PPT
Hypertextandhypermedia 120320065133-phpapp01
PDF
Chapter19 multimedia-091006115642-phpapp021-120309093503-phpapp02
PPT
Mutlimediaauthoringtools 120320065815-phpapp01
PPT
Multimedia tools (sound)
PPT
Multimedia tools(images)
PPTX
Anchor data type,cursor data type,array data type
Coddrules 120309094848-phpapp02
Coddrules 120309094807-phpapp01
Hypertextandhypermedia 120320065133-phpapp01
Chapter19 multimedia-091006115642-phpapp021-120309093503-phpapp02
Mutlimediaauthoringtools 120320065815-phpapp01
Multimedia tools (sound)
Multimedia tools(images)
Anchor data type,cursor data type,array data type

Recently uploaded (20)

PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
master seminar digital applications in india
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PDF
Classroom Observation Tools for Teachers
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Basic Mud Logging Guide for educational purpose
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial diseases, their pathogenesis and prophylaxis
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
master seminar digital applications in india
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Cell Types and Its function , kingdom of life
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Anesthesia in Laparoscopic Surgery in India
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
Classroom Observation Tools for Teachers
O7-L3 Supply Chain Operations - ICLT Program
Renaissance Architecture: A Journey from Faith to Humanism
Basic Mud Logging Guide for educational purpose
PPH.pptx obstetrics and gynecology in nursing
Module 4: Burden of Disease Tutorial Slides S2 2025

Algorithm 110801105245-phpapp01-120223065724-phpapp02

  • 2. Introduction to Algorithm ● An algorithm is finite set of steps defining the solution of a particular problem. ● It can be expressed in English like language, called pseudocode, in programming language or in the form of flowchart. www.eshikshak.co.in
  • 3. Characteristics ● Input – There are zero or more values which are externally supplied. ● Output – At least one value is produced ● Definiteness – Each step must be clear and unambiguous ● Finiteness – If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps ● Effectiveness – Each step must be sufficiently basic that it can in principal be carried out by a person using only paper and pencil www.eshikshak.co.in
  • 4. Algorithm Complexity ● There are basically two aspects of computer programming. ○ Data Organization (i.e Data & structure) ○ Algorithm ● The choice of a particular algorithm depends on the following consideration : ○ Time Complexity (Performance Requirements) ○ Space Complexity (Memory Requirements) www.eshikshak.co.in
  • 5. Space Complexity ● It means the amount of memory, algorithm or program needs to run to completion. ● Some of the reasons for studying space complexity are ○ If a multi user system ○ Sufficient memory is available to run the program www.eshikshak.co.in
  • 6. Space Complexity (Cont.) ● The space needed by a program consists of the following components. ○ Instruction Space : Space needed to store the executable version of the program ○ Data Space : Space needed to store all constants, variable values and has further following components ■ Constants, variables, structured variables like array and structure ■ Dynamically allocated space www.eshikshak.co.in
  • 7. Space Complexity (Cont.) ● Environmental Stack Space : Space needed to store the information needed to resume the suspended functions. ○ Return Address ○ Values of all local variables and the values of formal parameters in the function being involved. www.eshikshak.co.in
  • 8. Time Complexity ● It means the amount of time it needs to run to completion ● Reasons for studying time complexity ○ Interested to know in advance that whether a program will provide a satisfactory real time response ○ There may be several possible solutions with different time requirements www.eshikshak.co.in
  • 9. Expressing Space and Time Complexity ● The space and/or time complexity is usually expressed in form of the function f(n) ○ Where n is the input size for a given instance of the problem being solved. ● Expressing space and/ or time complexity as a function has following reasons ○ We may be interested to predict the rate of growth of complexity as the size of problem increases. ○ To Compare the complexities of two or more algorithm ○ Since in modern computers, the memory is not a sence constraint, therefore, our analysis of www.eshikshak.co.in algorithms will be on the basis of time complexity.
  • 10. Big ‘O’ Notation ● Big O is a characterization scheme that allows to measure properties of algorithms such time and space complexity. ● It is useful to set the prerequisites of algorithms and to develop and design efficient algorithms in terms of time and space complexity. www.eshikshak.co.in
  • 11. Categories of Algorithm ● Based on Big O notation, the algorithm can be categorized as follows ○ Constant time O(1) ○ Logarithmic time O(log n) ○ Linear time O(n) ○ Polynomial time O(nk) (for k > 1) ○ Exponentail time O(kn) for k > 1 www.eshikshak.co.in
  • 12. Algorithm Analysis ● Different ways or algorithms to solve a problem. ● Hence, some of the algorithm may be more efficient than the others ● There are different types of time complexities which can be analyzed for an algorithm ○ Best Case Time Analysis ○ Average Case Time Analysis ○ Worst Case Time Analysis www.eshikshak.co.in
  • 13. Best Case Time Complexity ● It is a measure of the minimum time that the algorithm will require for an input of size ‘n’. ● The running time of many algorithms varies not only for the inputs of different sizes but also for the different inputs of same size ○ Example : Sorting or Searching www.eshikshak.co.in
  • 14. Worst Case Time Complexity ● The worst case time complexity of an algorithm is a measure of the maximum time that the algorithm will require for an input of size ‘n’. ● Example : If ‘n’ input data items are supplied in reverse order for any sorting algorithm, the algorithm will require n2 operations to perform the sort. www.eshikshak.co.in
  • 15. Average Case Time Complexity ● The time that an algorithm will require to execute a typical input data of size ‘n’ is known as average case time complexity. www.eshikshak.co.in