SlideShare una empresa de Scribd logo
1 de 2
Recursion:
In front of each line of happyMe, indicate how many times that line runs in this program.
#include <iostream>
using namespace std;
void happyMe(int start) {
if (start <= 0){
cout << start << endl; return;
}
happyMe(start - 1);
happyMe(start - 2 );
}
int main(){
happyMe(5); return 0;
}
Solution
**The number of time happyMe is executed is marked as bold**
#include <iostream>
using namespace std;
void happyMe(int start)
{
if (start <= 0)
{
cout << start << endl; return;
}
//this line runs 24 times in the current program
happyMe(start - 1);
//this line runs 24 times in the current program
happyMe(start - 2 );
}
int main()
{
happyMe(5);
return 0;
}

Más contenido relacionado

Más de diegor62

International business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docxInternational business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docxdiegor62
 
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docxIntermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docxdiegor62
 
Integrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docxIntegrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docxdiegor62
 
Insight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docxInsight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docxdiegor62
 
Infrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docxInfrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docxdiegor62
 
Infrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docxInfrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docxdiegor62
 
Initial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docxInitial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docxdiegor62
 
Is the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docxIs the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docxdiegor62
 
Is my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docxIs my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docxdiegor62
 
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docxInorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docxdiegor62
 
Is it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docxIs it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docxdiegor62
 
INITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docxINITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docxdiegor62
 
Indonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docxIndonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docxdiegor62
 
Indicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docxIndicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docxdiegor62
 
In what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docxIn what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docxdiegor62
 
In view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docxIn view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docxdiegor62
 
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docxIN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docxdiegor62
 
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docxIn which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docxdiegor62
 
In which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docxIn which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docxdiegor62
 
In what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docxIn what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docxdiegor62
 

Más de diegor62 (20)

International business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docxInternational business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docx
 
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docxIntermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
 
Integrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docxIntegrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docx
 
Insight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docxInsight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docx
 
Infrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docxInfrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docx
 
Infrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docxInfrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docx
 
Initial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docxInitial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docx
 
Is the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docxIs the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docx
 
Is my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docxIs my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docx
 
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docxInorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
 
Is it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docxIs it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docx
 
INITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docxINITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docx
 
Indonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docxIndonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docx
 
Indicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docxIndicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docx
 
In what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docxIn what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docx
 
In view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docxIn view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docx
 
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docxIN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
 
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docxIn which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
 
In which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docxIn which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docx
 
In what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docxIn what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docx
 

Último

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 

Último (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 

Recursion- In front of each line of happyMe- indicate how many times t.docx

  • 1. Recursion: In front of each line of happyMe, indicate how many times that line runs in this program. #include <iostream> using namespace std; void happyMe(int start) { if (start <= 0){ cout << start << endl; return; } happyMe(start - 1); happyMe(start - 2 ); } int main(){ happyMe(5); return 0; } Solution **The number of time happyMe is executed is marked as bold** #include <iostream> using namespace std;
  • 2. void happyMe(int start) { if (start <= 0) { cout << start << endl; return; } //this line runs 24 times in the current program happyMe(start - 1); //this line runs 24 times in the current program happyMe(start - 2 ); } int main() { happyMe(5); return 0; }