Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago