SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
Lecture 2 : Role of Algorithms in
Computing
Jayavignesh T
Asst Professor
SENSE
What is an Algorithm?
• An algorithm is a set of rules for carrying out calculation
either by hand or on a machine.
• An algorithm is a finite step-by-step procedure to
achieve a required result.
• An algorithm is a sequence of computational steps that
transform the input into the output.
• An algorithm is a sequence of operations performed on
data that have to be organized in data structures.
• An algorithm is an abstraction of a program to be
executed on a physical machine (model of
Computation).
What is an Algorithm contd..?
• An algorithm is a sequence of unambiguous
instructions for solving a problem,
– i.e., for obtaining a required output for any
legitimate input in a finite amount of time
Requirements
• Recipe, process, method, technique, procedure, routine,… with
following requirements:
1. Finiteness
– terminates after a finite number of steps
2. Definiteness
– rigorously and unambiguously specified
3. Input
– valid inputs are clearly specified
4. Output
– can be proved to produce the correct output given a valid
input
5. Effectiveness
– steps are sufficiently simple and basic
Design and Analysis
• Algorithmic is a branch of computer science that
consists of designing and analyzing computer
algorithms
• The “design” pertain to
– The description of algorithm at an abstract level
by means of a pseudo language, and
– Proof of correctness that is, the algorithm solves
the given problem in all cases.
• The “analysis” deals with performance
evaluation(complexity analysis).
Design and Analysis
• It is not depended on programming language,
machine.
• Are mathematical entities, which can be thought of
as running on some sort of idealized computer with
an infinite random access memory
• Algorithm design is all about the mathematical
theory behind the design of good programs.
Why Analyze?
• Why analyze algorithms?
– Evaluate Algorithm performance
– Compare Different Algorithms
• Analyze what about them?
– Running time, Memory usage, Solution quality
– Worst-case and “typical” case
• Computational complexity
– Understanding the intrinsic difficulty of computational
problems – Classifying problems according to difficulty
– Algorithms provide upper bound to show problem is
hard, must show that any algorithm to solve it requires at
least a given amount of resources
Algorithm Problem solving
Understand the problem
Decision Making
Design an Algorithm
Prove Correctness
Analyze Algorithm
Code the Algorithm
Understand the problem
• Necessary Inputs to solve the
problem?
• Input – Instances
• Decide range of inputs
• To Fix Boundary values
• Work correctly for all Valid inputs
Decision Making
• Analyze the required inputs and decide on
– Computational Means
– Exact vs Approximate Solving
– Data Structures
– Algorithm Design Technique
 Computational Means
 Computational capability of running devices
 Sequential Algorithm ( Random Access Machine RAM)
 Parallel Algorithm (Piece executed on multiple processing
devices and put back together to get correct result)
 Proper choice of Computational device (Space/Time
efficient)
Decision Making contd..
• Exact vs Approximate Solving
• Exact Algorithm
– Problem needs to be solved exactly or correctly
• Approximation Algorithm
– Solve a complex problem, we will not get exact
solution
– Ex : Travelling salesman problem
• Data Structures
– Algorithm + Data Structures – Programming Language
– Proper Choice of Data Structures required before
designing actual algorithm
Algorithm Design Technique
• Strategy or Paradigm
– General approach to solve program
algorithmically
– Different problems from Different areas of
computing
• Brute Force :
– Straight forward technique with naïve approach
• Divide and Conquer :
– Problem is divided into smaller instances
Algorithm Design Technique contd..
• Decrease and Conquer :
– Instance size is decreased to solve the problem
• Transform and Conquer :
– Instance is modified and then solved
• Dynamic Programming :
– Results of smaller, reoccurring instances are
obtained to solve problem
• Greedy Technique :
– Solve the problem by making locally optimal
decisions
Specification of Algorithm
• Natural Language
– Drawback : Specification by this means not clear
• Pseudo Code
– Mixture of Natural Language + Programming constructs
ALGORITHM Sum(a,b)
// Problem Description : This algorithm performs addition of two
numbers
// Input : Two integers a and b
// Output : Addition of two integers
c a + b
return c
• Flow Chart
– Using Geometric Shapes containing descriptions of algorithm’s steps.
Proving Algorithm’s Correctness
• Prove algorithm yields required results
• For Every Legitimate Input in finite amount of
time
• If one instance of valid input, the algorithm
performs incorrectly !!
– Ex : Mathematical Induction
Analysis of Algorithm
• Time Efficiency
– Indicates how fast algorithm runs
• Space Efficiency
– How much Extra memory the algorithm needs to
complete its execution
• Simplicity
– Generating Sequence of instructions which are easy to
understand
• Generality
– Range of inputs it can accept
– Generality of problem which algorithm can solve
Coding an Algorithm
• Implementation of algorithm done by
suitable programming language
– C
– C++
– Java,
– Verilog etc etc…
Problem Types to solve
• Sorting Algorithms
–Arranging elements in increasing
(ascending) or decreasing (descending)
order
–Numbers, Characters, Strings
–Sorting makes easier to search elements
–Ex : Dictionary, Telephone books, Class
lists, Employee database etc..
Problem Types to solve
• Sorting Algorithms
–Properties
• Stable Property
–Preserves the relative order of any two
equal elements. Position i , j where i < j ,
sorted list i’ and j’ such that i’ < j’
• In Place Property
–Does not require extra memory, except for
possibly a few memory unit
Searching
• To find the desired element from the list
• Element to be Searched – Search Key
• Sequential Search
• Binary Search etc.
• Some Search algorithms work faster than
others but
– Requires more memory
– Works only in sorted arrays etc..
Linear Search Algorithm
• Input: An array of n numbers and an element which is required to
be searched in the given list
• Output: Number exists in the list or not.
Algorithm:
1. Input the size of list i.e. n
2. Read the n elements of array A
3. Input the item/element to be searched in the given list.
4. for each element in the array i=1 to n
5. if A[i]==item
6. Search successful, return
7. if i==n+1
8. Search unsuccessful.
9. Stop
Graph Problems
• Collection of points called vertices
• Some are connected by line segments – edges
• Graph traversal algorithms, shortest path
algorithms etc…
• String Processing
– String – sequence of characters
– Text Strings = Letters, numbers, special
characters, bit strings (0 & 1)
Combinatorial Problems
• Computing Permutations and combinations
• Complex computing due to
– As problem size grows the combinatorial objects
grow rapidly and reach to huge value
– No algorithm available which solves these
problems in finite amount of time.
– Many fall under unsolvable problems
Geometric Problems
• Deal with geometric objects such as
points, lines and polygons
• Applications in Computer Graphics,
Robotics and topography
Time Complexity
• Amount of computer time required by an algorithm
to run on completion
• Difficult to compute time complexity in terms of
physically clocked time.
• Drawbacks of measuring running time in-terms of
seconds, millisecond etc are
– Dependence of speed of a underlying hardware
– Number of other programs running (System load)
– Dependence of compiler used in generating
machine code
How to calculate running time then?
• Time complexity given in terms of FREQUENCY
COUNT
• Count denoting number of times of execution of
statement.
For (i=0; i <n;i++) { // St1 : 1, St 2 : n+1 , St 3 : n times
sum = sum + a[i]; // n times
}
3n + 2 ; O(n) neglecting constants and lower order terms
How to calculate running time then?
for (i=0; i < n ; i ++) // 1 ; n+1 ; n times
{
for (j=0; j < n ; j ++) // n ; n(n+1) ; n(n)
{
c[i][j] = a[i][j] + b[i][j];
}
}
3n2+4n+ 2 = O(n2)
How to calculate running time then?
• All Algorithms run longer on larger inputs
• Algorithm’s efficiency - f(n)
• Identify the most important operations of the
algorithm – BASIC Operation
• Basic operation – contributing to most of total
running time
• Compute the number of times basic operation is
executed (mostly in inner loop)
Ex : Sorting Algorithms – Comparison (< >)
Matrix Multiplication, Polynomial evaluation – Arithmetic Operations ( *, +)
= (assignment), ==(equality) etc..
Order of Growth of Algorithm
• Measuring the performance of an algorithm
in relation with input size n
Rate of Growth of Algorithm as fn of i/p size
Efficiency comparisons

Contenu connexe

Tendances

Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
sumitbardhan
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
Akshay Nagpurkar
 

Tendances (20)

Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventions
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 
First order logic
First order logicFirst order logic
First order logic
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Theory of Computation
Theory of ComputationTheory of Computation
Theory of Computation
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
 
Machine Learning with Decision trees
Machine Learning with Decision treesMachine Learning with Decision trees
Machine Learning with Decision trees
 
chapter 1
chapter 1chapter 1
chapter 1
 
Amdahl`s law -Processor performance
Amdahl`s law -Processor performanceAmdahl`s law -Processor performance
Amdahl`s law -Processor performance
 

En vedette

03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
Lincoln School
 
ATPG Methods and Algorithms
ATPG Methods and AlgorithmsATPG Methods and Algorithms
ATPG Methods and Algorithms
Deiptii Das
 

En vedette (20)

Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
#1 designandanalysis of algo
#1 designandanalysis of algo#1 designandanalysis of algo
#1 designandanalysis of algo
 
Slide1
Slide1Slide1
Slide1
 
03 algorithm properties
03 algorithm properties03 algorithm properties
03 algorithm properties
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 
Algorithm Design
Algorithm DesignAlgorithm Design
Algorithm Design
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
 
Analysis algorithm introduction Lecture# 1
Analysis algorithm introduction Lecture# 1Analysis algorithm introduction Lecture# 1
Analysis algorithm introduction Lecture# 1
 
Daa
DaaDaa
Daa
 
WHAT IS COMPUTER SCIENCE?
WHAT IS COMPUTER SCIENCE?WHAT IS COMPUTER SCIENCE?
WHAT IS COMPUTER SCIENCE?
 
ATPG Methods and Algorithms
ATPG Methods and AlgorithmsATPG Methods and Algorithms
ATPG Methods and Algorithms
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Insertion sorting
Insertion sortingInsertion sorting
Insertion sorting
 
35 algorithm-types
35 algorithm-types35 algorithm-types
35 algorithm-types
 

Similaire à Lecture 2 role of algorithms in computing

Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
rajesshs31r
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
rajesshs31r
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
AntareepMajumder
 
Unit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.pptUnit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.ppt
HODElex
 

Similaire à Lecture 2 role of algorithms in computing (20)

Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
Design & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptxDesign & Analysis of Algorithm course .pptx
Design & Analysis of Algorithm course .pptx
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.ppt
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.pptChapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.ppt
 
Analysis of Algorithms
Analysis of AlgorithmsAnalysis of Algorithms
Analysis of Algorithms
 
Daa
DaaDaa
Daa
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Unit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.pptUnit II_Searching and Sorting Algorithms.ppt
Unit II_Searching and Sorting Algorithms.ppt
 
Unit 2 algorithm
Unit   2 algorithmUnit   2 algorithm
Unit 2 algorithm
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
Algorithms.pdf
Algorithms.pdfAlgorithms.pdf
Algorithms.pdf
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
 

Dernier

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 

Dernier (20)

(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
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
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Lecture 2 role of algorithms in computing

  • 1. Lecture 2 : Role of Algorithms in Computing Jayavignesh T Asst Professor SENSE
  • 2. What is an Algorithm? • An algorithm is a set of rules for carrying out calculation either by hand or on a machine. • An algorithm is a finite step-by-step procedure to achieve a required result. • An algorithm is a sequence of computational steps that transform the input into the output. • An algorithm is a sequence of operations performed on data that have to be organized in data structures. • An algorithm is an abstraction of a program to be executed on a physical machine (model of Computation).
  • 3. What is an Algorithm contd..? • An algorithm is a sequence of unambiguous instructions for solving a problem, – i.e., for obtaining a required output for any legitimate input in a finite amount of time
  • 4. Requirements • Recipe, process, method, technique, procedure, routine,… with following requirements: 1. Finiteness – terminates after a finite number of steps 2. Definiteness – rigorously and unambiguously specified 3. Input – valid inputs are clearly specified 4. Output – can be proved to produce the correct output given a valid input 5. Effectiveness – steps are sufficiently simple and basic
  • 5. Design and Analysis • Algorithmic is a branch of computer science that consists of designing and analyzing computer algorithms • The “design” pertain to – The description of algorithm at an abstract level by means of a pseudo language, and – Proof of correctness that is, the algorithm solves the given problem in all cases. • The “analysis” deals with performance evaluation(complexity analysis).
  • 6. Design and Analysis • It is not depended on programming language, machine. • Are mathematical entities, which can be thought of as running on some sort of idealized computer with an infinite random access memory • Algorithm design is all about the mathematical theory behind the design of good programs.
  • 7. Why Analyze? • Why analyze algorithms? – Evaluate Algorithm performance – Compare Different Algorithms • Analyze what about them? – Running time, Memory usage, Solution quality – Worst-case and “typical” case • Computational complexity – Understanding the intrinsic difficulty of computational problems – Classifying problems according to difficulty – Algorithms provide upper bound to show problem is hard, must show that any algorithm to solve it requires at least a given amount of resources
  • 8. Algorithm Problem solving Understand the problem Decision Making Design an Algorithm Prove Correctness Analyze Algorithm Code the Algorithm
  • 9. Understand the problem • Necessary Inputs to solve the problem? • Input – Instances • Decide range of inputs • To Fix Boundary values • Work correctly for all Valid inputs
  • 10. Decision Making • Analyze the required inputs and decide on – Computational Means – Exact vs Approximate Solving – Data Structures – Algorithm Design Technique  Computational Means  Computational capability of running devices  Sequential Algorithm ( Random Access Machine RAM)  Parallel Algorithm (Piece executed on multiple processing devices and put back together to get correct result)  Proper choice of Computational device (Space/Time efficient)
  • 11. Decision Making contd.. • Exact vs Approximate Solving • Exact Algorithm – Problem needs to be solved exactly or correctly • Approximation Algorithm – Solve a complex problem, we will not get exact solution – Ex : Travelling salesman problem • Data Structures – Algorithm + Data Structures – Programming Language – Proper Choice of Data Structures required before designing actual algorithm
  • 12. Algorithm Design Technique • Strategy or Paradigm – General approach to solve program algorithmically – Different problems from Different areas of computing • Brute Force : – Straight forward technique with naïve approach • Divide and Conquer : – Problem is divided into smaller instances
  • 13. Algorithm Design Technique contd.. • Decrease and Conquer : – Instance size is decreased to solve the problem • Transform and Conquer : – Instance is modified and then solved • Dynamic Programming : – Results of smaller, reoccurring instances are obtained to solve problem • Greedy Technique : – Solve the problem by making locally optimal decisions
  • 14. Specification of Algorithm • Natural Language – Drawback : Specification by this means not clear • Pseudo Code – Mixture of Natural Language + Programming constructs ALGORITHM Sum(a,b) // Problem Description : This algorithm performs addition of two numbers // Input : Two integers a and b // Output : Addition of two integers c a + b return c • Flow Chart – Using Geometric Shapes containing descriptions of algorithm’s steps.
  • 15. Proving Algorithm’s Correctness • Prove algorithm yields required results • For Every Legitimate Input in finite amount of time • If one instance of valid input, the algorithm performs incorrectly !! – Ex : Mathematical Induction
  • 16. Analysis of Algorithm • Time Efficiency – Indicates how fast algorithm runs • Space Efficiency – How much Extra memory the algorithm needs to complete its execution • Simplicity – Generating Sequence of instructions which are easy to understand • Generality – Range of inputs it can accept – Generality of problem which algorithm can solve
  • 17. Coding an Algorithm • Implementation of algorithm done by suitable programming language – C – C++ – Java, – Verilog etc etc…
  • 18. Problem Types to solve • Sorting Algorithms –Arranging elements in increasing (ascending) or decreasing (descending) order –Numbers, Characters, Strings –Sorting makes easier to search elements –Ex : Dictionary, Telephone books, Class lists, Employee database etc..
  • 19. Problem Types to solve • Sorting Algorithms –Properties • Stable Property –Preserves the relative order of any two equal elements. Position i , j where i < j , sorted list i’ and j’ such that i’ < j’ • In Place Property –Does not require extra memory, except for possibly a few memory unit
  • 20. Searching • To find the desired element from the list • Element to be Searched – Search Key • Sequential Search • Binary Search etc. • Some Search algorithms work faster than others but – Requires more memory – Works only in sorted arrays etc..
  • 21. Linear Search Algorithm • Input: An array of n numbers and an element which is required to be searched in the given list • Output: Number exists in the list or not. Algorithm: 1. Input the size of list i.e. n 2. Read the n elements of array A 3. Input the item/element to be searched in the given list. 4. for each element in the array i=1 to n 5. if A[i]==item 6. Search successful, return 7. if i==n+1 8. Search unsuccessful. 9. Stop
  • 22. Graph Problems • Collection of points called vertices • Some are connected by line segments – edges • Graph traversal algorithms, shortest path algorithms etc… • String Processing – String – sequence of characters – Text Strings = Letters, numbers, special characters, bit strings (0 & 1)
  • 23. Combinatorial Problems • Computing Permutations and combinations • Complex computing due to – As problem size grows the combinatorial objects grow rapidly and reach to huge value – No algorithm available which solves these problems in finite amount of time. – Many fall under unsolvable problems
  • 24. Geometric Problems • Deal with geometric objects such as points, lines and polygons • Applications in Computer Graphics, Robotics and topography
  • 25. Time Complexity • Amount of computer time required by an algorithm to run on completion • Difficult to compute time complexity in terms of physically clocked time. • Drawbacks of measuring running time in-terms of seconds, millisecond etc are – Dependence of speed of a underlying hardware – Number of other programs running (System load) – Dependence of compiler used in generating machine code
  • 26. How to calculate running time then? • Time complexity given in terms of FREQUENCY COUNT • Count denoting number of times of execution of statement. For (i=0; i <n;i++) { // St1 : 1, St 2 : n+1 , St 3 : n times sum = sum + a[i]; // n times } 3n + 2 ; O(n) neglecting constants and lower order terms
  • 27. How to calculate running time then? for (i=0; i < n ; i ++) // 1 ; n+1 ; n times { for (j=0; j < n ; j ++) // n ; n(n+1) ; n(n) { c[i][j] = a[i][j] + b[i][j]; } } 3n2+4n+ 2 = O(n2)
  • 28. How to calculate running time then? • All Algorithms run longer on larger inputs • Algorithm’s efficiency - f(n) • Identify the most important operations of the algorithm – BASIC Operation • Basic operation – contributing to most of total running time • Compute the number of times basic operation is executed (mostly in inner loop) Ex : Sorting Algorithms – Comparison (< >) Matrix Multiplication, Polynomial evaluation – Arithmetic Operations ( *, +) = (assignment), ==(equality) etc..
  • 29.
  • 30. Order of Growth of Algorithm • Measuring the performance of an algorithm in relation with input size n
  • 31. Rate of Growth of Algorithm as fn of i/p size