SlideShare a Scribd company logo
1 of 22
Discrete Mathematics And it’s Applications
Algorithms
Group # 01
BSIT-3rd –B-Morning
Members
 Muhammad Waqar Munir
 Rehan Ali
 Farooq Shah
 Jahanzaib Shahid
 Muhammad Hammad
Algorithms Methodology:
 Construct a model that translates the
problem into a mathematical context
 Build a method that will solve the
general problem using the model
 Ideally, we need a procedure that
follows a sequence of steps that leads
to the desired answer, such a
sequence is called an Algorithm.
History:
The term Algorithm is a corruption of the
name Al-Khowarizmi (mathematician of the
9th century)
Algorithms
 What is an algorithms?
An Algorithm is a finite set of precise instructions for performing a
computation or for solving a problem.
• Finding the Maximum Element in a Finite
Sequence
procedure max(a1, a2, . . . , an: integers)
max := a1
for i := 2 to n
if max < ai then max := ai
return max{max is the largest element}
Properties of algorithms:
 Inputfrom a specified set.
 Outputfrom a specified set (solution)
 Correctness of output for every possible input.
 Definiteness of evert step in the computation
 Effectiveness of each calculation step and
 Generality for a class of problems.
Searching Algorithms
 The problem of locating an element in an ordered list occurs in
many contexts. For instance, a
 program that checks the spelling of words searches for them in a
dictionary, which is just an
 ordered list of words. Problems of this kind are called searching
problems.
THE LINEAR SEARCH
The first algorithm that we will present is called the linear search,
or sequential search, algorithm.
• ALGORITHM For The Linear Search
procedure linear search(x: integer, a1, a2, . . . , an: distinct
integers)
i := 1
while (i ≤ n and x = ai )
i := i + 1
if i ≤ n then location := i
else location := 0
return location{location is the subscript of the term that equals
x, or is 0 if x is not found}
THE BINARY SEARCH
Some Instructions:
• if the
terms are numbers, they are listed from smallest to largest
• if they are words, they are listed
in lexicographic, or alphabetic, order
can be used when the list has terms occurring in order of
increasing size.
Binary Search
 May only b used on a sorted array.
 Eliminates one half of the elements after each comparison.
 Locate the middle of the array.
 Compare the value at that location with the search key.
 If they are equal-done.
 Otherwise, decide which half of the array contains the search key.
 Repeat the search on that half of the array and ignore the other half.
 The search continues until the key is matched or no elements remain to be
sorted.
• ALGORITHM For The Binary Search
procedure binary search (x: integer, a1, a2, . . . , an:
increasing integers)
i := 1{i is left endpoint of search interval}
j := n {j is right endpoint of search interval}
while i < j
m := (i + j)/2
if x > am then i := m + 1
else j := m
if x = ai then location := i
else location := 0
return location{location is the subscript i of the term ai
equal to x, or 0 if x is not found}
Sorting
 Goal
“Ordering the elements”
for example, sorting the list 7,2,1,4,5,9
produces the list 1,2,4,5,7,9.
Similarly, sorting of list d, h, c, a, f
produces a, c, d, f, h.
BUBBLE SORT
The bubble sort is one of the simplest
sorting algorithms, but not one of the most
efficient. It puts a list into increasing order by
successively comparing adjacent elements,
interchanging them if they are in the wrong
order.
The Bubble Sort algorithm looks at the pairs of entries in the
array, and swaps their order if needed.
• ALGORITHM For The Bubble Sort
procedure bubble sort(a1, . . . , an : real numbers with n ≥ 2)
for i := 1 to n − 1
for j := 1 to n − i
if aj > aj+1 then interchange aj and aj+1
{a1, . . . , an is in increasing order}
INSERTION SORT
• The insertion sort is a simple sorting
algorithm, but it is usually not the most
efficient.
• To sort a list with n elements,
• insertion sort begins with the second
element.
• ALGORITHM For Insertion Sort
procedure insertion sort(a1, a2, . . . , an:
real numbers with n ≥ 2)
for j := 2 to n
i := 1
while aj > ai
i := i + 1
m := aj
for k := 0 to j − i − 1
aj−k := aj−k−1
ai := m
{a1, . . . , an is in increasing order}
Greedy Algorithms
• to find a solution to the given problem that either
minimizes or maximizes the value of some
parameter
• one of the simplest approaches often leads to a
solution of an optimization Problem.
Algorithms that make what seems to be the “best” choice at each
step are called greedy algorithms.
• ALGORITHM For Greedy Change-
Making Algorithm
procedure change(c1, c2, . . . , cr : values
of denominations of coins, where
c1 > c2 > ・ ・ ・ > cr ; n: a positive
integer)
for i := 1 to r
di := 0 {di counts the coins of denomination
ci used}
while n ≥ ci
di := di + 1 {add a coin of denomination ci}
n := n − ci
{di is the number of coins of denomination
ci in the change for i = 1, 2, . . . , r}
TheHaltingProblem
• these are unsolvable problems, called halting
problem.
• a problem that cannot be solved using any
procedure.
• We will describe Turing’s proof that the halting
problem is unsolvable.
Algorithms
Algorithms

More Related Content

What's hot (20)

Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
 
Red black tree
Red black treeRed black tree
Red black tree
 
Binary search
Binary searchBinary search
Binary search
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Hash table
Hash tableHash table
Hash table
 
8 queen problem
8 queen problem8 queen problem
8 queen problem
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
chapter 1
chapter 1chapter 1
chapter 1
 
Lecture 04 syntax analysis
Lecture 04 syntax analysisLecture 04 syntax analysis
Lecture 04 syntax analysis
 
Activity selection problem
Activity selection problemActivity selection problem
Activity selection problem
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Merge Sort
Merge SortMerge Sort
Merge Sort
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
 
Algorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching AlgorithmsAlgorithms Lecture 6: Searching Algorithms
Algorithms Lecture 6: Searching Algorithms
 
Hashing
HashingHashing
Hashing
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 

Similar to Algorithms

Similar to Algorithms (20)

Lect-2.pptx
Lect-2.pptxLect-2.pptx
Lect-2.pptx
 
21-algorithms.ppt
21-algorithms.ppt21-algorithms.ppt
21-algorithms.ppt
 
21-algorithms.ppt
21-algorithms.ppt21-algorithms.ppt
21-algorithms.ppt
 
Algorithm, Pseudocode and Flowcharting in C++
Algorithm, Pseudocode and Flowcharting in C++Algorithm, Pseudocode and Flowcharting in C++
Algorithm, Pseudocode and Flowcharting in C++
 
21-algorithms (1).ppt
21-algorithms (1).ppt21-algorithms (1).ppt
21-algorithms (1).ppt
 
Chapter3.pptx
Chapter3.pptxChapter3.pptx
Chapter3.pptx
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Unit viii searching and hashing
Unit   viii searching and hashing Unit   viii searching and hashing
Unit viii searching and hashing
 
Ada notes
Ada notesAda notes
Ada notes
 
Searching
Searching Searching
Searching
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
 
Lecture_Oct26.pptx
Lecture_Oct26.pptxLecture_Oct26.pptx
Lecture_Oct26.pptx
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Solution 3.
Solution 3.Solution 3.
Solution 3.
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
Perform brute force
Perform brute forcePerform brute force
Perform brute force
 
In the binary search, if the array being searched has 32 elements in.pdf
In the binary search, if the array being searched has 32 elements in.pdfIn the binary search, if the array being searched has 32 elements in.pdf
In the binary search, if the array being searched has 32 elements in.pdf
 
Searching techniques with progrms
Searching techniques with progrmsSearching techniques with progrms
Searching techniques with progrms
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

Algorithms

  • 1. Discrete Mathematics And it’s Applications Algorithms
  • 2. Group # 01 BSIT-3rd –B-Morning Members  Muhammad Waqar Munir  Rehan Ali  Farooq Shah  Jahanzaib Shahid  Muhammad Hammad
  • 3. Algorithms Methodology:  Construct a model that translates the problem into a mathematical context  Build a method that will solve the general problem using the model  Ideally, we need a procedure that follows a sequence of steps that leads to the desired answer, such a sequence is called an Algorithm. History: The term Algorithm is a corruption of the name Al-Khowarizmi (mathematician of the 9th century)
  • 4. Algorithms  What is an algorithms? An Algorithm is a finite set of precise instructions for performing a computation or for solving a problem.
  • 5. • Finding the Maximum Element in a Finite Sequence procedure max(a1, a2, . . . , an: integers) max := a1 for i := 2 to n if max < ai then max := ai return max{max is the largest element}
  • 6. Properties of algorithms:  Inputfrom a specified set.  Outputfrom a specified set (solution)  Correctness of output for every possible input.  Definiteness of evert step in the computation  Effectiveness of each calculation step and  Generality for a class of problems.
  • 7. Searching Algorithms  The problem of locating an element in an ordered list occurs in many contexts. For instance, a  program that checks the spelling of words searches for them in a dictionary, which is just an  ordered list of words. Problems of this kind are called searching problems.
  • 8. THE LINEAR SEARCH The first algorithm that we will present is called the linear search, or sequential search, algorithm. • ALGORITHM For The Linear Search procedure linear search(x: integer, a1, a2, . . . , an: distinct integers) i := 1 while (i ≤ n and x = ai ) i := i + 1 if i ≤ n then location := i else location := 0 return location{location is the subscript of the term that equals x, or is 0 if x is not found}
  • 9. THE BINARY SEARCH Some Instructions: • if the terms are numbers, they are listed from smallest to largest • if they are words, they are listed in lexicographic, or alphabetic, order can be used when the list has terms occurring in order of increasing size.
  • 10. Binary Search  May only b used on a sorted array.  Eliminates one half of the elements after each comparison.  Locate the middle of the array.  Compare the value at that location with the search key.  If they are equal-done.  Otherwise, decide which half of the array contains the search key.  Repeat the search on that half of the array and ignore the other half.  The search continues until the key is matched or no elements remain to be sorted.
  • 11. • ALGORITHM For The Binary Search procedure binary search (x: integer, a1, a2, . . . , an: increasing integers) i := 1{i is left endpoint of search interval} j := n {j is right endpoint of search interval} while i < j m := (i + j)/2 if x > am then i := m + 1 else j := m if x = ai then location := i else location := 0 return location{location is the subscript i of the term ai equal to x, or 0 if x is not found}
  • 12. Sorting  Goal “Ordering the elements” for example, sorting the list 7,2,1,4,5,9 produces the list 1,2,4,5,7,9. Similarly, sorting of list d, h, c, a, f produces a, c, d, f, h.
  • 13. BUBBLE SORT The bubble sort is one of the simplest sorting algorithms, but not one of the most efficient. It puts a list into increasing order by successively comparing adjacent elements, interchanging them if they are in the wrong order. The Bubble Sort algorithm looks at the pairs of entries in the array, and swaps their order if needed.
  • 14.
  • 15. • ALGORITHM For The Bubble Sort procedure bubble sort(a1, . . . , an : real numbers with n ≥ 2) for i := 1 to n − 1 for j := 1 to n − i if aj > aj+1 then interchange aj and aj+1 {a1, . . . , an is in increasing order}
  • 16. INSERTION SORT • The insertion sort is a simple sorting algorithm, but it is usually not the most efficient. • To sort a list with n elements, • insertion sort begins with the second element.
  • 17. • ALGORITHM For Insertion Sort procedure insertion sort(a1, a2, . . . , an: real numbers with n ≥ 2) for j := 2 to n i := 1 while aj > ai i := i + 1 m := aj for k := 0 to j − i − 1 aj−k := aj−k−1 ai := m {a1, . . . , an is in increasing order}
  • 18. Greedy Algorithms • to find a solution to the given problem that either minimizes or maximizes the value of some parameter • one of the simplest approaches often leads to a solution of an optimization Problem. Algorithms that make what seems to be the “best” choice at each step are called greedy algorithms.
  • 19. • ALGORITHM For Greedy Change- Making Algorithm procedure change(c1, c2, . . . , cr : values of denominations of coins, where c1 > c2 > ・ ・ ・ > cr ; n: a positive integer) for i := 1 to r di := 0 {di counts the coins of denomination ci used} while n ≥ ci di := di + 1 {add a coin of denomination ci} n := n − ci {di is the number of coins of denomination ci in the change for i = 1, 2, . . . , r}
  • 20. TheHaltingProblem • these are unsolvable problems, called halting problem. • a problem that cannot be solved using any procedure. • We will describe Turing’s proof that the halting problem is unsolvable.