SlideShare a Scribd company logo
1 of 2
1) Defining recursive functions
Defining recursive functions I have made up a sequence called a tribonacci sequence. The first
three numbers of this sequence are 1, 2 and 3, and every subsequent number in this sequence is
the sum of the previous three numbers. Thus, the sequence is 1,2,3,6,11,20,37,68,.... Write a
function to compute the n th tribonacci number. Assuming the 1st number is 1.
2) Counting recursive function calls
How many calls are made to tribonacci if the original call is tribonacci(5)?
Solution
1.int function (int n)
{ if (n<3)
return 1;
if (n>=3)
return function(n-1) + function(n-2) + function(n-3);
}
2.if the call is tribfunction(5) then
n>3
return( tribfunction(4)+ tribfunction(3)+ ftribunction(2)->3 calls
truibfunction(4)=. tribfunction(3)+tribfunction(2)+tribfunction(1)=>3 more calls
in all there will be 6 calls
1) Defining recursive functions Defining recursive functions I have ma.docx

More Related Content

Similar to 1) Defining recursive functions Defining recursive functions I have ma.docx

Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 
dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)Mumtaz Ali
 
13 recursion-120712074623-phpapp02
13 recursion-120712074623-phpapp0213 recursion-120712074623-phpapp02
13 recursion-120712074623-phpapp02Abdul Samee
 
Excel function
Excel functionExcel function
Excel functionSirajRock
 
Copy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerCopy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerJoepang2015
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesjayavignesh86
 
06 Recursion in C.pptx
06 Recursion in C.pptx06 Recursion in C.pptx
06 Recursion in C.pptxMouDhara1
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
101 math short cuts [www.onlinebcs.com]
101 math short cuts [www.onlinebcs.com]101 math short cuts [www.onlinebcs.com]
101 math short cuts [www.onlinebcs.com]Itmona
 

Similar to 1) Defining recursive functions Defining recursive functions I have ma.docx (20)

Recursion.pdf
Recursion.pdfRecursion.pdf
Recursion.pdf
 
3.pdf
3.pdf3.pdf
3.pdf
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
Recursion.ppt
 Recursion.ppt Recursion.ppt
Recursion.ppt
 
5 2
5 25 2
5 2
 
dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)
 
13 recursion-120712074623-phpapp02
13 recursion-120712074623-phpapp0213 recursion-120712074623-phpapp02
13 recursion-120712074623-phpapp02
 
Excel function
Excel functionExcel function
Excel function
 
Copy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerCopy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquer
 
Recursion
RecursionRecursion
Recursion
 
Lecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrencesLecture 5 6_7 - divide and conquer and method of solving recurrences
Lecture 5 6_7 - divide and conquer and method of solving recurrences
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
06 Recursion in C.pptx
06 Recursion in C.pptx06 Recursion in C.pptx
06 Recursion in C.pptx
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Ss 2013 midterm
Ss 2013 midtermSs 2013 midterm
Ss 2013 midterm
 
Ss 2013 midterm
Ss 2013 midtermSs 2013 midterm
Ss 2013 midterm
 
6-Python-Recursion.pdf
6-Python-Recursion.pdf6-Python-Recursion.pdf
6-Python-Recursion.pdf
 
101 math short cuts [www.onlinebcs.com]
101 math short cuts [www.onlinebcs.com]101 math short cuts [www.onlinebcs.com]
101 math short cuts [www.onlinebcs.com]
 

More from deant5

Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docxHello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docxdeant5
 
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docxhe above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docxdeant5
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docxdeant5
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docxdeant5
 
Halogens tend to have high- I- electronegativities II- solublity in a.docx
Halogens tend to have high-  I- electronegativities II- solublity in a.docxHalogens tend to have high-  I- electronegativities II- solublity in a.docx
Halogens tend to have high- I- electronegativities II- solublity in a.docxdeant5
 
Heat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docxHeat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docxdeant5
 
he following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docxhe following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docxdeant5
 
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docxhe following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docxdeant5
 
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docxHarriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docxdeant5
 
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxHarris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxdeant5
 
Gwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxGwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxdeant5
 
Gordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docxGordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docxdeant5
 
Goodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docxGoodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docxdeant5
 
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docxdeant5
 
1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docxdeant5
 
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docxdeant5
 
1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docxdeant5
 
1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docxdeant5
 
1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docxdeant5
 
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docxdeant5
 

More from deant5 (20)

Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docxHello- please use EULERS METHOD to solve and graph this- Please show -.docx
Hello- please use EULERS METHOD to solve and graph this- Please show -.docx
 
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docxhe above pictures best represents a solid lonic A) picture (a) B) pict.docx
he above pictures best represents a solid lonic A) picture (a) B) pict.docx
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co (1).docx
 
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docxHeidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
Heidi Design acquired 20- of the outstanding common stock of Quigly Co.docx
 
Halogens tend to have high- I- electronegativities II- solublity in a.docx
Halogens tend to have high-  I- electronegativities II- solublity in a.docxHalogens tend to have high-  I- electronegativities II- solublity in a.docx
Halogens tend to have high- I- electronegativities II- solublity in a.docx
 
Heat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docxHeat transfer summary questionsSolutionThermal energy is related to th.docx
Heat transfer summary questionsSolutionThermal energy is related to th.docx
 
he following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docxhe following accounts were taken from ABC CompanySolutionCalculation o.docx
he following accounts were taken from ABC CompanySolutionCalculation o.docx
 
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docxhe following accounts were taken from ABC CompanySolutionCalculation o (1).docx
he following accounts were taken from ABC CompanySolutionCalculation o (1).docx
 
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docxHarriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
Harriet Pandel- an employer- is subject to FICA taxes but exempt from.docx
 
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docxHarris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
Harris Fell- CPA and member of the AICPA- was engaged to audit the fin.docx
 
Gwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docxGwen and Paul are deciding how to split their time between writing mus.docx
Gwen and Paul are deciding how to split their time between writing mus.docx
 
Gordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docxGordon Corporation reported the following equity section on its curren.docx
Gordon Corporation reported the following equity section on its curren.docx
 
Goodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docxGoodwill would appear in which balance sheet section- a- Investments b.docx
Goodwill would appear in which balance sheet section- a- Investments b.docx
 
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx1- A genetic map is a(an) set of identical copies of DNA segments from.docx
1- A genetic map is a(an) set of identical copies of DNA segments from.docx
 
1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx1- A buyout involving the target firms current management is called a.docx
1- A buyout involving the target firms current management is called a.docx
 
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
1- 2- 3- 5- Part B Constants- Periodic Table nteractive 3D display mod.docx
 
1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx1- (TCO 5) Which form type displays records in a tabular format simila.docx
1- (TCO 5) Which form type displays records in a tabular format simila.docx
 
1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx1- (TCO F) Which of the following is correct with respect to Internal.docx
1- (TCO F) Which of the following is correct with respect to Internal.docx
 
1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx1- (Learning Objective 2- Describe components of internal control) Lis.docx
1- (Learning Objective 2- Describe components of internal control) Lis.docx
 
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx1)What are the advantages and disadvantages for MNEs to provide post-a.docx
1)What are the advantages and disadvantages for MNEs to provide post-a.docx
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 

Recently uploaded (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

1) Defining recursive functions Defining recursive functions I have ma.docx

  • 1. 1) Defining recursive functions Defining recursive functions I have made up a sequence called a tribonacci sequence. The first three numbers of this sequence are 1, 2 and 3, and every subsequent number in this sequence is the sum of the previous three numbers. Thus, the sequence is 1,2,3,6,11,20,37,68,.... Write a function to compute the n th tribonacci number. Assuming the 1st number is 1. 2) Counting recursive function calls How many calls are made to tribonacci if the original call is tribonacci(5)? Solution 1.int function (int n) { if (n<3) return 1; if (n>=3) return function(n-1) + function(n-2) + function(n-3); } 2.if the call is tribfunction(5) then n>3 return( tribfunction(4)+ tribfunction(3)+ ftribunction(2)->3 calls truibfunction(4)=. tribfunction(3)+tribfunction(2)+tribfunction(1)=>3 more calls in all there will be 6 calls