SlideShare a Scribd company logo
1 of 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;
}

More Related Content

More from 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
 

More from 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
 

Recently uploaded

The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...Nguyen Thanh Tu Collection
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeSaadHumayun7
 
Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfaedhbteg
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointELaRue0
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Mark Carrigan
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online PresentationGDSCYCCE
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringDenish Jangid
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya - UEM Kolkata Quiz Club
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptxmanishaJyala2
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxnuriaiuzzolino1
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonMayur Khatri
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Mohamed Rizk Khodair
 

Recently uploaded (20)

The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
 
Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdf
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon season
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 

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; }