SlideShare a Scribd company logo
1 of 36
Recurrent Problem
Motivation
We will explore three sample problems that give a feel for what’s to come.
They have two traits in common:
 Investigated repeatedly
 Solutions all use the idea of recurrence
• Solution to each problem depends on the solutions to smaller instances of the same problem.
Problems with Recursive Solution
Easy to solve small problem.
Refers to previous steps and so on becomes hard to solve problems that are
relatively large.
Closed Form
An expression that can be expressed analytically in terms of a finite
number of certain "well-known" functions.
 Elementary Functions
o Constants
o One variable
o Finite number of exponentials or logarithms or roots of polynomial
o Four elementary operations (+ – × ÷).
Steps to Solve A Problem
Look at small cases.
Find and prove a mathematical expression for the quantity of interest.
Recurrence Relation.
Find and prove a closed form for our mathematical expression. Prove
the closed form using mathematical induction
Recurrent Problems
The Tower of Hanoi
The Lines in The Plane
The Josephus Problem
Tower of Hanoi Problem
Invented by the French mathematician Edouard Lucas in 1883.
Given a tower of n disks, initially stacked in decreasing size on one of three pegs.
The objective is
 Transfer the entire tower to one of the other pegs.
 Move only one disk at a time.
 Never move a larger one onto a smaller.
Tower of Hanoi : 3 Disks START
BEG AUX END
Tower of Hanoi : 3 Disks FINISH
BEG AUX END
Tower of Hanoi : Recursive Solution
Let’s call the three peg BEG(Source), AUX(Auxiliary) and END(Destination).
1) Move the top N – 1 disks from the BEG to AUX tower using END
2) Move the Nth disk from BEG to END tower
3) Move the N – 1 disks from AUX tower to END tower using BEG
Tower of Hanoi : 3 Disks
BEG AUX END
Move n-1 disks from BEG to AUX using END
Tower of Hanoi : 3 Disks
BEG AUX END
Tower of Hanoi : 3 Disks
BEG AUX END
Tower of Hanoi : 3 Disks
BEG AUX END
Move largest one from BEG to END
Tower of Hanoi : 3 Disks
BEG AUX END
Move n-1 disks from AUX to END using BEG
Tower of Hanoi : 3 Disks
BEG AUX END
Tower of Hanoi : 3 Disks
BEG AUX END
Tower of Hanoi : 3 Disks
BEG AUX END
Tower of Hanoi : No. of Moves, Tn
• for 1 disk it takes 1 move to transfer 1 disk from BEG to END;
• for 2 disks, it will take 3 moves: 2 Tn-1 + 1 = 2(1) + 1 = 3
• for 3 disks, it will take 7 moves: 2 Tn-1 + 1 = 2(3) + 1 = 7
• for 4 disks, it will take 15 moves: 2 Tn-1 + 1 = 2(7) + 1 = 15
• for 5 disks, it will take 31 moves: 2 Tn-1 + 1 = 2(15) + 1 = 31
• for 6 disks... ?
Tower of Hanoi : No. of Moves, Tn
• Explicit Pattern
Number of Disks Number of Moves
1 1
2 3
3 7
4 15
5 31
T0 = 0
Tn = 2 Tn-1 + 1,n>0
Tower of Hanoi : Recursive Solution Difficulties
T7 = ?
T7 = 2 T6 + 1
= 2(2 T5 + 1) + 1
= 4(2 T4 + 1) + 3
= 8(2 T3 + 1) + 7
= 16(2 T2 + 1) + 15
= 32(2 T1 + 1) + 31
= 64(2 T0 + 1) + 63
= 64 × 0 + 64+ 63
= 127
T50 = ?
T50 = 2 T49 + 1
= 2(2 T48 + 1) + 1
= 4(2 T47 + 1) + 3
= 8(2 T46 + 1) + 7
……………………….
=?
Tower of Hanoi : Finding Closed Form
• Explicit Pattern
Number of Disks Number of Moves
1 1
2 3
3 7
4 15
5 31
• Powers of two help reveal the pattern
Number of Disks Number of Moves
1 21 - 1 = 2 - 1 = 1
2 22 - 1 = 4 - 1 = 3
3 23 - 1 = 8 - 1 = 7
4 24 - 1 = 16 - 1 = 15
5 25 - 1 = 32 - 1 = 31
Tn = 2 n - 1
A Closed Form
Tower of Hanoi : Proving Closed Form
Basis : For n= 0, T0 = 2n – 1 = 20 – 1 = 0
Induction : Let for n = n-1 the expression is true, then Tn-1 = 2n-1 – 1
Hypothesis : For n = n ,
Tn = 2 Tn-1 + 1
= 2 (2n-1 – 1 ) + 1
= 2n-1+1 – 2 + 1
= 2n – 1
Lines in The Plane Problem
Popularly: How many slices of pizza can a person obtain by making n
straight cuts with a pizza knife?
Academically: What is the maximum number Ln of regions defined by n
lines in the plane?
Lines in The Plane : Recursive Solution
Draw lines so that they intersect each others
Calculate maximum number of regions created by lines
Lines in The Plane : N = 0
L0 = 1
Lines in The Plane : N = 1
L1 = 2
Lines in The Plane : N = 2
L2 = 4
Lines in The Plane : N = 3
L3 = 7
Lines in The Plane : N = 4
L4 = 11
Lines in The Plane : Maximum No. of Regions, Ln
• for 0 line it creates 1 region;
• for 1 lines, it creates 2 region; : Ln-1 + n = 1 + 1 = 2
• for 2 lines, it creates 4 region; : Ln-1 + n = 2 + 2 = 4
• for 3 lines, it will take 7 region: Ln-1 + n = 4 + 3 = 7
• for 4 lines, it will take 10 region: Ln-1 + n = 7 + 4 = 11
• for 5 lines... ?
L0 = 1
Ln = Ln-1 + n, n>0
Lines in The Plane : Recursive Solution Difficulties
L7 = ?
L7 = L6 + 7
= L5 + 6 + 7
= L4 + 5+ 13
= L3 + 4 + 18
= L2 + 3 + 22
= L1 + 2 + 25
= L0 + 1 + 27
= 1+ 28
= 29
L50 = ?
L50 = L49 + 50
= L48 + 49+ 50
= L47 + 48+ 99
= L46 + 47 +14 7
……………………….
=?
Lines in The Plane: Finding Closed Form
Ln = Ln-1 + n
= Ln-2 + (n-1) + n
= Ln-3 + (n-2) + (n-1) + n
= Ln-2 + (n-3) + (n-2) + (n-1) + n
……………………..
= L0 + 1 + 2 + …… + (n-3) + (n-2) + (n-1) + n
= 1 +
𝒏(𝒏+𝟏)
𝟐
Lines in The Plane : Proving Closed Form
Basis : For n= 0, L0 = 1 +
𝟎(𝟎+𝟏)
𝟐
= 1
Induction : Let for n = n-1 the expression is true, then Ln-1 = 1 +
𝒏(𝒏 − 𝟏)
𝟐
Hypothesis : For n = n ,
Ln = Ln-1 + n
= 1 +
𝒏(𝒏 − 𝟏)
𝟐
+ n
= 1 +
𝒏𝟐
− 𝒏 + 𝟐𝒏
𝟐
= 1 +
𝒏𝟐
+ 𝒏
𝟐
= 1 +
𝒏(𝒏 + 𝟏)
𝟐
Josephus Problem
Do it Yourself
Solve Exercises
The End

More Related Content

Similar to Recurrent Problem in Discrete Mathmatics.pptx

pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqPradeep Bisht
 
Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...
Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...
Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...Kasun Ranga Wijeweera
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structuresKàŕtheek Jåvvàjí
 
Tower of Hanoi Investigation
Tower of Hanoi InvestigationTower of Hanoi Investigation
Tower of Hanoi InvestigationWriters Per Hour
 
ECES302 Exam 1 Solutions
ECES302 Exam 1 SolutionsECES302 Exam 1 Solutions
ECES302 Exam 1 SolutionsThomas Woo
 
Recursion - Computer Algorithms
Recursion - Computer AlgorithmsRecursion - Computer Algorithms
Recursion - Computer AlgorithmsAlaa Al-Makhzoomy
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................nourhandardeer3
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03Krish_ver2
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsAqeel Rafique
 
April 8, 2014
April 8, 2014April 8, 2014
April 8, 2014khyps13
 
100 Combinatorics Problems (With Solutions)
100 Combinatorics Problems (With Solutions)100 Combinatorics Problems (With Solutions)
100 Combinatorics Problems (With Solutions)Courtney Esco
 
Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...
Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...
Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...Telenor
 

Similar to Recurrent Problem in Discrete Mathmatics.pptx (20)

pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...
Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...
Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with...
 
Branch and bounding : Data structures
Branch and bounding : Data structuresBranch and bounding : Data structures
Branch and bounding : Data structures
 
Tower of Hanoi Investigation
Tower of Hanoi InvestigationTower of Hanoi Investigation
Tower of Hanoi Investigation
 
Chapter9 4
Chapter9 4Chapter9 4
Chapter9 4
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
ECES302 Exam 1 Solutions
ECES302 Exam 1 SolutionsECES302 Exam 1 Solutions
ECES302 Exam 1 Solutions
 
Recursion - Computer Algorithms
Recursion - Computer AlgorithmsRecursion - Computer Algorithms
Recursion - Computer Algorithms
 
Graph
GraphGraph
Graph
 
Graph
GraphGraph
Graph
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
5.2 divede and conquer 03
5.2 divede and conquer 035.2 divede and conquer 03
5.2 divede and conquer 03
 
Binomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relationsBinomial Theorem, Recursion ,Tower of Honai, relations
Binomial Theorem, Recursion ,Tower of Honai, relations
 
Heuristic search
Heuristic searchHeuristic search
Heuristic search
 
April 8, 2014
April 8, 2014April 8, 2014
April 8, 2014
 
100 Combinatorics Problems (With Solutions)
100 Combinatorics Problems (With Solutions)100 Combinatorics Problems (With Solutions)
100 Combinatorics Problems (With Solutions)
 
Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...
Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...
Equations Complex Numbers Quadratic Expressions Inequalities Absolute Value E...
 

Recently uploaded

Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...shivangimorya083
 
Digi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxDigi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxTanveerAhmed817946
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 

Recently uploaded (20)

Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Decoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in ActionDecoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in Action
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
 
Digi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxDigi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 

Recurrent Problem in Discrete Mathmatics.pptx

  • 2. Motivation We will explore three sample problems that give a feel for what’s to come. They have two traits in common:  Investigated repeatedly  Solutions all use the idea of recurrence • Solution to each problem depends on the solutions to smaller instances of the same problem.
  • 3. Problems with Recursive Solution Easy to solve small problem. Refers to previous steps and so on becomes hard to solve problems that are relatively large.
  • 4. Closed Form An expression that can be expressed analytically in terms of a finite number of certain "well-known" functions.  Elementary Functions o Constants o One variable o Finite number of exponentials or logarithms or roots of polynomial o Four elementary operations (+ – × ÷).
  • 5. Steps to Solve A Problem Look at small cases. Find and prove a mathematical expression for the quantity of interest. Recurrence Relation. Find and prove a closed form for our mathematical expression. Prove the closed form using mathematical induction
  • 6. Recurrent Problems The Tower of Hanoi The Lines in The Plane The Josephus Problem
  • 7. Tower of Hanoi Problem Invented by the French mathematician Edouard Lucas in 1883. Given a tower of n disks, initially stacked in decreasing size on one of three pegs. The objective is  Transfer the entire tower to one of the other pegs.  Move only one disk at a time.  Never move a larger one onto a smaller.
  • 8. Tower of Hanoi : 3 Disks START BEG AUX END
  • 9. Tower of Hanoi : 3 Disks FINISH BEG AUX END
  • 10. Tower of Hanoi : Recursive Solution Let’s call the three peg BEG(Source), AUX(Auxiliary) and END(Destination). 1) Move the top N – 1 disks from the BEG to AUX tower using END 2) Move the Nth disk from BEG to END tower 3) Move the N – 1 disks from AUX tower to END tower using BEG
  • 11. Tower of Hanoi : 3 Disks BEG AUX END Move n-1 disks from BEG to AUX using END
  • 12. Tower of Hanoi : 3 Disks BEG AUX END
  • 13. Tower of Hanoi : 3 Disks BEG AUX END
  • 14. Tower of Hanoi : 3 Disks BEG AUX END Move largest one from BEG to END
  • 15. Tower of Hanoi : 3 Disks BEG AUX END Move n-1 disks from AUX to END using BEG
  • 16. Tower of Hanoi : 3 Disks BEG AUX END
  • 17. Tower of Hanoi : 3 Disks BEG AUX END
  • 18. Tower of Hanoi : 3 Disks BEG AUX END
  • 19. Tower of Hanoi : No. of Moves, Tn • for 1 disk it takes 1 move to transfer 1 disk from BEG to END; • for 2 disks, it will take 3 moves: 2 Tn-1 + 1 = 2(1) + 1 = 3 • for 3 disks, it will take 7 moves: 2 Tn-1 + 1 = 2(3) + 1 = 7 • for 4 disks, it will take 15 moves: 2 Tn-1 + 1 = 2(7) + 1 = 15 • for 5 disks, it will take 31 moves: 2 Tn-1 + 1 = 2(15) + 1 = 31 • for 6 disks... ?
  • 20. Tower of Hanoi : No. of Moves, Tn • Explicit Pattern Number of Disks Number of Moves 1 1 2 3 3 7 4 15 5 31 T0 = 0 Tn = 2 Tn-1 + 1,n>0
  • 21. Tower of Hanoi : Recursive Solution Difficulties T7 = ? T7 = 2 T6 + 1 = 2(2 T5 + 1) + 1 = 4(2 T4 + 1) + 3 = 8(2 T3 + 1) + 7 = 16(2 T2 + 1) + 15 = 32(2 T1 + 1) + 31 = 64(2 T0 + 1) + 63 = 64 × 0 + 64+ 63 = 127 T50 = ? T50 = 2 T49 + 1 = 2(2 T48 + 1) + 1 = 4(2 T47 + 1) + 3 = 8(2 T46 + 1) + 7 ………………………. =?
  • 22. Tower of Hanoi : Finding Closed Form • Explicit Pattern Number of Disks Number of Moves 1 1 2 3 3 7 4 15 5 31 • Powers of two help reveal the pattern Number of Disks Number of Moves 1 21 - 1 = 2 - 1 = 1 2 22 - 1 = 4 - 1 = 3 3 23 - 1 = 8 - 1 = 7 4 24 - 1 = 16 - 1 = 15 5 25 - 1 = 32 - 1 = 31 Tn = 2 n - 1 A Closed Form
  • 23. Tower of Hanoi : Proving Closed Form Basis : For n= 0, T0 = 2n – 1 = 20 – 1 = 0 Induction : Let for n = n-1 the expression is true, then Tn-1 = 2n-1 – 1 Hypothesis : For n = n , Tn = 2 Tn-1 + 1 = 2 (2n-1 – 1 ) + 1 = 2n-1+1 – 2 + 1 = 2n – 1
  • 24. Lines in The Plane Problem Popularly: How many slices of pizza can a person obtain by making n straight cuts with a pizza knife? Academically: What is the maximum number Ln of regions defined by n lines in the plane?
  • 25. Lines in The Plane : Recursive Solution Draw lines so that they intersect each others Calculate maximum number of regions created by lines
  • 26. Lines in The Plane : N = 0 L0 = 1
  • 27. Lines in The Plane : N = 1 L1 = 2
  • 28. Lines in The Plane : N = 2 L2 = 4
  • 29. Lines in The Plane : N = 3 L3 = 7
  • 30. Lines in The Plane : N = 4 L4 = 11
  • 31. Lines in The Plane : Maximum No. of Regions, Ln • for 0 line it creates 1 region; • for 1 lines, it creates 2 region; : Ln-1 + n = 1 + 1 = 2 • for 2 lines, it creates 4 region; : Ln-1 + n = 2 + 2 = 4 • for 3 lines, it will take 7 region: Ln-1 + n = 4 + 3 = 7 • for 4 lines, it will take 10 region: Ln-1 + n = 7 + 4 = 11 • for 5 lines... ? L0 = 1 Ln = Ln-1 + n, n>0
  • 32. Lines in The Plane : Recursive Solution Difficulties L7 = ? L7 = L6 + 7 = L5 + 6 + 7 = L4 + 5+ 13 = L3 + 4 + 18 = L2 + 3 + 22 = L1 + 2 + 25 = L0 + 1 + 27 = 1+ 28 = 29 L50 = ? L50 = L49 + 50 = L48 + 49+ 50 = L47 + 48+ 99 = L46 + 47 +14 7 ………………………. =?
  • 33. Lines in The Plane: Finding Closed Form Ln = Ln-1 + n = Ln-2 + (n-1) + n = Ln-3 + (n-2) + (n-1) + n = Ln-2 + (n-3) + (n-2) + (n-1) + n …………………….. = L0 + 1 + 2 + …… + (n-3) + (n-2) + (n-1) + n = 1 + 𝒏(𝒏+𝟏) 𝟐
  • 34. Lines in The Plane : Proving Closed Form Basis : For n= 0, L0 = 1 + 𝟎(𝟎+𝟏) 𝟐 = 1 Induction : Let for n = n-1 the expression is true, then Ln-1 = 1 + 𝒏(𝒏 − 𝟏) 𝟐 Hypothesis : For n = n , Ln = Ln-1 + n = 1 + 𝒏(𝒏 − 𝟏) 𝟐 + n = 1 + 𝒏𝟐 − 𝒏 + 𝟐𝒏 𝟐 = 1 + 𝒏𝟐 + 𝒏 𝟐 = 1 + 𝒏(𝒏 + 𝟏) 𝟐
  • 35. Josephus Problem Do it Yourself Solve Exercises