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 // needed to perform C++ I/O #include #include //use absolute function #include //use clock_t start, stop; using namespace std;

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; }

*I have the all the base code below and screen shot of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!