SlideShare a Scribd company logo
1 of 21
Lecture 6
Architecture
Algorithm Definition
Algorithm
1stDefinition:
Sequence of steps that can be taken to solve a problem
2ndDefinition:
The step by step series of activities performed in a sequence
to solve a problem
Better Definition:
A precise sequence of a limited number of unambiguous,
executable steps that terminates in the form of a solution
Why Algorithms are Useful?
•Once we find an algorithm for solving a problem, we
do not need to re-discover it the next time we are
faced with that problem
•Once an algorithm is known, the task of solving the
problem reduces to following (almost blindly and
without thinking) the instructions precisely
•All the knowledge required for solving the problem is
present in the algorithm
Origin of the Term “Algorithm”
 The name derives from the title of a Latin book:
Algoritmi de numero Indorum
 That book was written by the famous 9-th century
Muslim mathematician, Muhammad ibn Musa al-
Khwarizmi
 The study of algorithms began with mathematicians
and was a significant area of work in the early years
Al-Khwarizmi’s Golden Principle
All complex problems can be and must be solved
using the following simple steps:
 Break down the problem into small, simple sub-
problems
 Arrange the sub-problems in such an order that each
of them can be solved without effecting any other
 Solve them separately, in the correct order
 Combine the solutions of the sub-problems to form
the solution of the original problem
Algorithm for Decimal to Binary
Conversion
 Write the decimal number
 Divide by 2; write quotient and remainder
 Repeat step 2 on the quotient; keep on repeating
until the quotient becomes zero
 Write all remainder digits in the reverse order (last
remainder first) to form the final result
Remember
 The process consists of repeated application of
simple steps
 All steps are unambiguous (clearly defined)
 We are capable of doing all those steps
 Only a limited no. of steps needs to be taken
 Once all those steps are taken according to the
prescribed sequence, the required result will be
found
 Moreover, the process will stop at that point
Three Requirements
Sequence is:
 Precise
Consists of a limited number of steps
Each step is:
 Unambiguous
 Executable
The sequence of steps terminates in the form of a
solution
Analysis of Algorithms
 Analysis in the context of algorithms is concerned
with predicting the resources that re requires:
 Computational time
 Memory
 Bandwidth
 Logic functions
However, Time – generally measured in terms of the
number of steps required to execute an algorithm - is
the resource of most interest. By analyzing several
candidate algorithms, the most efficient one(s) can
be identified
Selecting Among Algorithms
 When choosing among competing, successful
solutions to a problem, choose the one which is the
least complex
 This principle is called the “Ockham’s Razor,” after
William of Ockham - famous 13-th century English
philosopher
Types of Algorithms
Greedy Algorithm
 An algorithm that always takes the best immediate,
or local solution while finding an answer
 Greedy algorithms may find the overall or globally
optimal solution for some optimization problems, but
may find less-than-optimal solutions for some
instances of other problems
 KEY ADVANTAGE: Greedy algorithms are usually
faster, since they don't consider the details of
possible alternatives
Deterministic Algorithm
 An algorithm whose behavior can be completely
predicted from the inputs
 That is, each time a certain set of input is presented,
the algorithm gives the same results as any other
time the set of input is presented.
Types of Algorithms
Randomized Algorithm
 Any algorithm whose behavior is not only determined
by the input, but also values produced by a random
number generator
 These algorithms are often simpler and more
efficient than deterministic algorithms for the same
problem
 Simpler algorithms have the advantages of being
easier to analyze and implement.
Types of Algorithms
Travelling Salesman Problem
The Brute Force Strategy
 A strategy in which all possible combinations are
examined and the best among them is selected
 What is the problem with this approach?
 A: Doesn’t scale well with the size of the problem
 How many possible city sequences for n=6? For
n=60? For n=600?
Syntax & Semantics
Algorithm Representation
 Flow chart
 Pseudo code
 Actual code
Flow chart
 A graphical representation of a process (e.g. an
algorithm), in which graphic objects are used to
indicate the steps & decisions that are taken as the
process moves along from start to finish
 Individual steps are represented by boxes and other
shapes on the flowchart, with arrows between those
shapes indicating the order in which the steps are
taken
Flowchart Elements
Ic lecture6 architecture and algo
Ic lecture6 architecture and algo

More Related Content

What's hot

What's hot (20)

Daa presentation 97
Daa presentation 97Daa presentation 97
Daa presentation 97
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
 
Lecture 1-cs648
Lecture 1-cs648Lecture 1-cs648
Lecture 1-cs648
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture NotesDesign & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
 
Notion of an algorithm
Notion of an algorithmNotion of an algorithm
Notion of an algorithm
 
Types of algorithms
Types of algorithmsTypes of algorithms
Types of algorithms
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
 
Empirical analysis
Empirical analysisEmpirical analysis
Empirical analysis
 
Topic 1.4: Randomized Algorithms
Topic 1.4: Randomized AlgorithmsTopic 1.4: Randomized Algorithms
Topic 1.4: Randomized Algorithms
 
Ds03 algorithms jyoti lakhani
Ds03 algorithms jyoti lakhaniDs03 algorithms jyoti lakhani
Ds03 algorithms jyoti lakhani
 
Randomized Algorithms
Randomized AlgorithmsRandomized Algorithms
Randomized Algorithms
 
What is an algorithm?
What is an algorithm?What is an algorithm?
What is an algorithm?
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision tableProgramming aids- Algorithm, Flowchart, Pseudocodes and Decision table
Programming aids- Algorithm, Flowchart, Pseudocodes and Decision table
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
35 algorithm-types
35 algorithm-types35 algorithm-types
35 algorithm-types
 
Ada notes
Ada notesAda notes
Ada notes
 
Algorithms : Introduction and Analysis
Algorithms : Introduction and AnalysisAlgorithms : Introduction and Analysis
Algorithms : Introduction and Analysis
 

Similar to Ic lecture6 architecture and algo

Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.pptALIZAIB KHAN
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxsatvikkushwaha1
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptxShaistaRiaz4
 
19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdfGOWTHAMR721887
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdfishan743441
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptxRAJESH S
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptxRAJESH S
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptxSayanSen36
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.pptRaoHamza24
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notesProf. Dr. K. Adisesha
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of AlgorithmsBulbul Agrawal
 
Algorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptxAlgorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptxApasra R
 
Algorithms. Basic course
Algorithms. Basic courseAlgorithms. Basic course
Algorithms. Basic courseISS Art, LLC
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfMAJDABDALLAH3
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design PresentationKawsar Ahmed
 

Similar to Ic lecture6 architecture and algo (20)

Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
 
CH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptxCH-1.1 Introduction (1).pptx
CH-1.1 Introduction (1).pptx
 
Algo_Lecture01.pptx
Algo_Lecture01.pptxAlgo_Lecture01.pptx
Algo_Lecture01.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
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
 
mmmmmmm
mmmmmmmmmmmmmm
mmmmmmm
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
 
Unit 2 algorithm
Unit   2 algorithmUnit   2 algorithm
Unit 2 algorithm
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Algorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptxAlgorithm and Complexity-Lesson 1.pptx
Algorithm and Complexity-Lesson 1.pptx
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
 
Algorithms. Basic course
Algorithms. Basic courseAlgorithms. Basic course
Algorithms. Basic course
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 

More from AttaullahRahimoon (13)

Lecture 14-15-16-presentation skills and tips
Lecture 14-15-16-presentation skills and tipsLecture 14-15-16-presentation skills and tips
Lecture 14-15-16-presentation skills and tips
 
Lecture 11a-
Lecture 11a-Lecture 11a-
Lecture 11a-
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 1 a
Lecture 1 aLecture 1 a
Lecture 1 a
 
Ict lecture11b,12,13
Ict lecture11b,12,13 Ict lecture11b,12,13
Ict lecture11b,12,13
 
Ict lecture9 10
Ict lecture9 10 Ict lecture9 10
Ict lecture9 10
 
Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
Ic lecture7
Ic lecture7  Ic lecture7
Ic lecture7
 
Ic lecture4
Ic lecture4Ic lecture4
Ic lecture4
 
Ic lecture3
Ic lecture3Ic lecture3
Ic lecture3
 
Ic lecture2
Ic lecture2Ic lecture2
Ic lecture2
 
Ic lecture1
Ic lecture1Ic lecture1
Ic lecture1
 
Active and passive
Active and passiveActive and passive
Active and passive
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Ic lecture6 architecture and algo

  • 2. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step by step series of activities performed in a sequence to solve a problem Better Definition: A precise sequence of a limited number of unambiguous, executable steps that terminates in the form of a solution
  • 3. Why Algorithms are Useful? •Once we find an algorithm for solving a problem, we do not need to re-discover it the next time we are faced with that problem •Once an algorithm is known, the task of solving the problem reduces to following (almost blindly and without thinking) the instructions precisely •All the knowledge required for solving the problem is present in the algorithm
  • 4. Origin of the Term “Algorithm”  The name derives from the title of a Latin book: Algoritmi de numero Indorum  That book was written by the famous 9-th century Muslim mathematician, Muhammad ibn Musa al- Khwarizmi  The study of algorithms began with mathematicians and was a significant area of work in the early years
  • 5. Al-Khwarizmi’s Golden Principle All complex problems can be and must be solved using the following simple steps:  Break down the problem into small, simple sub- problems  Arrange the sub-problems in such an order that each of them can be solved without effecting any other  Solve them separately, in the correct order  Combine the solutions of the sub-problems to form the solution of the original problem
  • 6. Algorithm for Decimal to Binary Conversion  Write the decimal number  Divide by 2; write quotient and remainder  Repeat step 2 on the quotient; keep on repeating until the quotient becomes zero  Write all remainder digits in the reverse order (last remainder first) to form the final result
  • 7. Remember  The process consists of repeated application of simple steps  All steps are unambiguous (clearly defined)  We are capable of doing all those steps  Only a limited no. of steps needs to be taken  Once all those steps are taken according to the prescribed sequence, the required result will be found  Moreover, the process will stop at that point
  • 8. Three Requirements Sequence is:  Precise Consists of a limited number of steps Each step is:  Unambiguous  Executable The sequence of steps terminates in the form of a solution
  • 9. Analysis of Algorithms  Analysis in the context of algorithms is concerned with predicting the resources that re requires:  Computational time  Memory  Bandwidth  Logic functions However, Time – generally measured in terms of the number of steps required to execute an algorithm - is the resource of most interest. By analyzing several candidate algorithms, the most efficient one(s) can be identified
  • 10. Selecting Among Algorithms  When choosing among competing, successful solutions to a problem, choose the one which is the least complex  This principle is called the “Ockham’s Razor,” after William of Ockham - famous 13-th century English philosopher
  • 11. Types of Algorithms Greedy Algorithm  An algorithm that always takes the best immediate, or local solution while finding an answer  Greedy algorithms may find the overall or globally optimal solution for some optimization problems, but may find less-than-optimal solutions for some instances of other problems  KEY ADVANTAGE: Greedy algorithms are usually faster, since they don't consider the details of possible alternatives
  • 12. Deterministic Algorithm  An algorithm whose behavior can be completely predicted from the inputs  That is, each time a certain set of input is presented, the algorithm gives the same results as any other time the set of input is presented. Types of Algorithms
  • 13. Randomized Algorithm  Any algorithm whose behavior is not only determined by the input, but also values produced by a random number generator  These algorithms are often simpler and more efficient than deterministic algorithms for the same problem  Simpler algorithms have the advantages of being easier to analyze and implement. Types of Algorithms
  • 15. The Brute Force Strategy  A strategy in which all possible combinations are examined and the best among them is selected  What is the problem with this approach?  A: Doesn’t scale well with the size of the problem  How many possible city sequences for n=6? For n=60? For n=600?
  • 17. Algorithm Representation  Flow chart  Pseudo code  Actual code
  • 18. Flow chart  A graphical representation of a process (e.g. an algorithm), in which graphic objects are used to indicate the steps & decisions that are taken as the process moves along from start to finish  Individual steps are represented by boxes and other shapes on the flowchart, with arrows between those shapes indicating the order in which the steps are taken