Question
*I have the all the base code below and screen shot of output sample* (a) Write recursive and iterative functions for rabbit, writeBackward, and binarySearch
*I have the all the base code below and screen shot of output sample*
(a) Write recursive and iterative functions for rabbit, writeBackward, and binarySearch to compare by execution time.
Modify the cheer function to print "Hurrah" first and then type a recursive function to print a non-negative integer to the screen with its decimal digits stacked vertically.
#include
long double rabbit(int n); long double IterativeRabbit(int n); void writeBackward(string s); void IterativewriteBackward(string s);
int binarySearch(const int anArray[], int first, int last, int target); int IterativeBinarySearch(int array[], int size, int target); void cheers(int n); void verticalDigits(int num2);
const int SIZE = 40, SIZE2 = 10000;
int main() { cout
for (int i = 0; i
string s = "think";
clock_t start, stop;
//Rabbit functions start = clock(); res = rabbit(SIZE); stop = clock(); cout (stop - start)
start = clock(); res = IterativeRabbit(SIZE); stop = clock(); cout (stop - start)
//writeBackward functions
cout (stop - start)
cout (stop - start)
cout
//binary search functions start = clock(); res = binarySearch(array2, 0, SIZE2 - 1, 3261); stop = clock(); cout (stop - start)
start = clock(); res = IterativeBinarySearch(array2, SIZE2, 3261); stop = clock(); cout (stop - start)
//# 4- b cout
cout
int num2 = -1234; cout
system("pause"); return 0; }
Step 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