Menu

Programming Write Program Empirically Determine Performance Two Power Functions Implementa Q43871346

Programming Write a program to empirically determine the performance of two power functions implementations: Iterative implem

Programming Write a program to empirically determine the performance of two power functions implementations: Iterative implementation double iterativePower(double base, int exponent) { double retVal = 1.0; if (exponent < 0){ return 1.0 / iterativePower(base, -exponent); }else{ for (int i=0; i<exponent; i++) retVal *= base; return retVal; Recursive implementation double recursivePower(double base, int exponent){ if (exponent < 0){ return 1.0 / recursivePower (base, -exponent); }else if (exponent == 0){ return 1.0; }else { return base * recursivePower (base, exponent – 1); The program needs to measure the time it takes to call each of these functions for several values of n (exponent), you can set the base to 3.14159265359. The program will create a CSV file containing the following fields: n, iterative-time, recursive-time. The experiment should run to biggest possible value of n that your computer allows. Show transcribed image text Programming Write a program to empirically determine the performance of two power functions implementations: Iterative implementation double iterativePower(double base, int exponent) { double retVal = 1.0; if (exponent

Expert Answer


Answer to Programming Write a program to empirically determine the performance of two power functions implementations: Iterative i…

OR