SlideShare une entreprise Scribd logo
1  sur  1
Télécharger pour lire hors ligne
Consider the two functions below which both compute the value of f(n). The function f1 was
replaced with f2 because integer multiplications () were found to take 4 times longer than integer
additions (+).
int f1(n : integer)
if (n == 1) then return(1)
else return(2 f1(n 1));
int f2(n : integer)
if (n == 1) then return(1)
else return(f2(n 1) + f2(n 1));
i. Give a recurrence relation for f1, which satisfies the number of multiplications (*) executed as
a function of n.
ii. Solve the recurrence relation from Part i.
iii. Give a recurrence relation for f2, which satisfies the number of additions (+) executed as a
function of n.
iv. Solve the recurrence relation from Part iii. v. Both functions compute the same function f.
Was it a good idea to replace f1 with f2?

Contenu connexe

Plus de americancolor

Consider the following scenarioIn the last few weeks, residents h.pdf
Consider the following scenarioIn the last few weeks, residents h.pdfConsider the following scenarioIn the last few weeks, residents h.pdf
Consider the following scenarioIn the last few weeks, residents h.pdf
americancolor
 
convert this python code to java script. Make sure it works on Eclip.pdf
convert this python code to java script. Make sure it works on Eclip.pdfconvert this python code to java script. Make sure it works on Eclip.pdf
convert this python code to java script. Make sure it works on Eclip.pdf
americancolor
 
Control en Netflix Los gerentes no solo controlan los procesos d.pdf
Control en Netflix Los gerentes no solo controlan los procesos d.pdfControl en Netflix Los gerentes no solo controlan los procesos d.pdf
Control en Netflix Los gerentes no solo controlan los procesos d.pdf
americancolor
 
CONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdf
CONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdfCONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdf
CONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdf
americancolor
 
Contesta las preguntas del siguiente p�rrafo �Deber�a respons.pdf
Contesta las preguntas del siguiente p�rrafo �Deber�a respons.pdfContesta las preguntas del siguiente p�rrafo �Deber�a respons.pdf
Contesta las preguntas del siguiente p�rrafo �Deber�a respons.pdf
americancolor
 
Continental Airlines vuela alto con su almac�n de datos en tiempo re.pdf
Continental Airlines vuela alto con su almac�n de datos en tiempo re.pdfContinental Airlines vuela alto con su almac�n de datos en tiempo re.pdf
Continental Airlines vuela alto con su almac�n de datos en tiempo re.pdf
americancolor
 

Plus de americancolor (20)

Consider the following scenarioIn the last few weeks, residents h.pdf
Consider the following scenarioIn the last few weeks, residents h.pdfConsider the following scenarioIn the last few weeks, residents h.pdf
Consider the following scenarioIn the last few weeks, residents h.pdf
 
Consider the following wage regression in which you have data on gen.pdf
Consider the following wage regression in which you have data on gen.pdfConsider the following wage regression in which you have data on gen.pdf
Consider the following wage regression in which you have data on gen.pdf
 
core issue in frank by ocbc singapore case studyIn 2010, Jin Kang .pdf
core issue in frank by ocbc singapore case studyIn 2010, Jin Kang .pdfcore issue in frank by ocbc singapore case studyIn 2010, Jin Kang .pdf
core issue in frank by ocbc singapore case studyIn 2010, Jin Kang .pdf
 
Coronado Corporation tuvo una utilidad neta de $240 000 y pag� divid.pdf
Coronado Corporation tuvo una utilidad neta de $240 000 y pag� divid.pdfCoronado Corporation tuvo una utilidad neta de $240 000 y pag� divid.pdf
Coronado Corporation tuvo una utilidad neta de $240 000 y pag� divid.pdf
 
convert this python code to java script. Make sure it works on Eclip.pdf
convert this python code to java script. Make sure it works on Eclip.pdfconvert this python code to java script. Make sure it works on Eclip.pdf
convert this python code to java script. Make sure it works on Eclip.pdf
 
Convert M9 to a regular expression. Consider the following generalis.pdf
Convert M9 to a regular expression. Consider the following generalis.pdfConvert M9 to a regular expression. Consider the following generalis.pdf
Convert M9 to a regular expression. Consider the following generalis.pdf
 
Control en Netflix Los gerentes no solo controlan los procesos d.pdf
Control en Netflix Los gerentes no solo controlan los procesos d.pdfControl en Netflix Los gerentes no solo controlan los procesos d.pdf
Control en Netflix Los gerentes no solo controlan los procesos d.pdf
 
CONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdf
CONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdfCONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdf
CONTRATO DE ARRENDAMIENTO COMERCIAL Este Contrato de Arrendamiento C.pdf
 
Contrast the oral and poster method of presenting research at a conf.pdf
Contrast the oral and poster method of presenting research at a conf.pdfContrast the oral and poster method of presenting research at a conf.pdf
Contrast the oral and poster method of presenting research at a conf.pdf
 
Contribution Margin Molly Company sells 40,000 units at $14 per unit.pdf
Contribution Margin Molly Company sells 40,000 units at $14 per unit.pdfContribution Margin Molly Company sells 40,000 units at $14 per unit.pdf
Contribution Margin Molly Company sells 40,000 units at $14 per unit.pdf
 
ContextualizeWhat are YOUR learning goals What are the course .pdf
ContextualizeWhat are YOUR learning goals What are the course .pdfContextualizeWhat are YOUR learning goals What are the course .pdf
ContextualizeWhat are YOUR learning goals What are the course .pdf
 
Contesta las preguntas del siguiente p�rrafo �Deber�a respons.pdf
Contesta las preguntas del siguiente p�rrafo �Deber�a respons.pdfContesta las preguntas del siguiente p�rrafo �Deber�a respons.pdf
Contesta las preguntas del siguiente p�rrafo �Deber�a respons.pdf
 
CONTABILIDAD GERENCIAL - DECLARACIONES VERDADERAS O FALSAS.(SALTE .pdf
CONTABILIDAD GERENCIAL - DECLARACIONES VERDADERAS O FALSAS.(SALTE .pdfCONTABILIDAD GERENCIAL - DECLARACIONES VERDADERAS O FALSAS.(SALTE .pdf
CONTABILIDAD GERENCIAL - DECLARACIONES VERDADERAS O FALSAS.(SALTE .pdf
 
Continental Airlines vuela alto con su almac�n de datos en tiempo re.pdf
Continental Airlines vuela alto con su almac�n de datos en tiempo re.pdfContinental Airlines vuela alto con su almac�n de datos en tiempo re.pdf
Continental Airlines vuela alto con su almac�n de datos en tiempo re.pdf
 
Consider this scenario. Miguel is an experienced forensic evidence a.pdf
Consider this scenario. Miguel is an experienced forensic evidence a.pdfConsider this scenario. Miguel is an experienced forensic evidence a.pdf
Consider this scenario. Miguel is an experienced forensic evidence a.pdf
 
Considere una econom�a donde la industria dominante es la producci�n.pdf
Considere una econom�a donde la industria dominante es la producci�n.pdfConsidere una econom�a donde la industria dominante es la producci�n.pdf
Considere una econom�a donde la industria dominante es la producci�n.pdf
 
Considere una econom�a descrita por las siguientes ecuacionesY .pdf
Considere una econom�a descrita por las siguientes ecuacionesY .pdfConsidere una econom�a descrita por las siguientes ecuacionesY .pdf
Considere una econom�a descrita por las siguientes ecuacionesY .pdf
 
Considere un pa�s con un producto interno bruto (PIB) nominal de $ 1.pdf
Considere un pa�s con un producto interno bruto (PIB) nominal de $ 1.pdfConsidere un pa�s con un producto interno bruto (PIB) nominal de $ 1.pdf
Considere un pa�s con un producto interno bruto (PIB) nominal de $ 1.pdf
 
Considere todo lo que ha aprendido en este curso sobre problemas soc.pdf
Considere todo lo que ha aprendido en este curso sobre problemas soc.pdfConsidere todo lo que ha aprendido en este curso sobre problemas soc.pdf
Considere todo lo que ha aprendido en este curso sobre problemas soc.pdf
 
Considere los virus en soluci�n como una suspensi�n. �C�mo esperar�a.pdf
Considere los virus en soluci�n como una suspensi�n. �C�mo esperar�a.pdfConsidere los virus en soluci�n como una suspensi�n. �C�mo esperar�a.pdf
Considere los virus en soluci�n como una suspensi�n. �C�mo esperar�a.pdf
 

Dernier

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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
heathfieldcps1
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
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
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
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
 
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.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
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
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 

Consider the two functions below which both compute the value of f(n.pdf

  • 1. Consider the two functions below which both compute the value of f(n). The function f1 was replaced with f2 because integer multiplications () were found to take 4 times longer than integer additions (+). int f1(n : integer) if (n == 1) then return(1) else return(2 f1(n 1)); int f2(n : integer) if (n == 1) then return(1) else return(f2(n 1) + f2(n 1)); i. Give a recurrence relation for f1, which satisfies the number of multiplications (*) executed as a function of n. ii. Solve the recurrence relation from Part i. iii. Give a recurrence relation for f2, which satisfies the number of additions (+) executed as a function of n. iv. Solve the recurrence relation from Part iii. v. Both functions compute the same function f. Was it a good idea to replace f1 with f2?