I need help finding the Run Time Analysis of these code(s): Provide the tightest big-Oh bound on the run time for each of the following methods. Please explain how you got the answer and why it is case.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question

I need help finding the Run Time Analysis of these code(s): Provide the tightest big-Oh bound on the run time for each of the following methods. Please explain how you got the answer and why it is case.  

d.
void jedi (int n)
{
if( n <= 147 )
time += 54;
else
{
for (int i=0; i<n/2; i++)
time++;
jedi (n/3);
for (int i=0; i<13*n; i++)
time++;
jedi ( (2*n) /3);
}
}
Transcribed Image Text:d. void jedi (int n) { if( n <= 147 ) time += 54; else { for (int i=0; i<n/2; i++) time++; jedi (n/3); for (int i=0; i<13*n; i++) time++; jedi ( (2*n) /3); } }
i.
int pow (double x, int n)
{
if( n==0 )
return 1;
else
{
double halfpower = pow (x,n/2);
if( n % 2 == 0 )
{
return halfpower*halfpower;
}
else
{
return halfpower*halfpower*x;
}
}
}
Transcribed Image Text:i. int pow (double x, int n) { if( n==0 ) return 1; else { double halfpower = pow (x,n/2); if( n % 2 == 0 ) { return halfpower*halfpower; } else { return halfpower*halfpower*x; } } }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT