Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me code the following in: JAVA! Please read the instructions THOROUGHLY and use many COMMENTS! Full points will be awarded, thanks in advance!
Please help me code the following in: JAVA!
Please read the instructions THOROUGHLY and use many COMMENTS!
Full points will be awarded, thanks in advance!
3. The Exponent Function In this section, we will build two recursive functions and roughly compare their respective performance. Write a method that produces the result of x" by observing the following recurrence relationships: (1) x 1 (2) x"-x*x when n>0 Verify your method produces the correct value by writing a main that tests it. In the same class, write another function that will also recursively solve for exponential values, but will do so by cutting our problem in half at each step (rather than moving the solution along incrementally by subtracting one from n at each step). This new relationship is defined by the piecewise function: 0 (1) x 1 (2) x"-(xl2)2 when n is even (3) x": x * ( x"n-1)/2 ) )2 when n is odd To obtain the desired speedup, make sure your new function recursively calls itself no more than once in the body of the method. Once you have built this new recursive method, you should be able to redirect your main to test its output. Do so, and compare the execution times for large n with the old implementation - which is faster, and why? 1. Answer the following questions in comments in your code 2. Build a polynomial f1(x) for the first exponent function a. Next, select a reference function g(x) that will dominate the f1(x) function in question b. Finally, for g(x) find witnesses c, k such that |f1(x) k? 3. Build a polynomial f2(x) for the second exponent function Select a g(x) reference function Find witnesses c, k to prove the class of Big O for the second a. bStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started