Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that inputs one-character commands that instruct the program to run one of the recursive functions below. Use switch to select function. Output

Write a program that inputs one-character commands that instruct the program to run one of the recursive functions below. Use switch to select function. Output appropriate results. All I/O should be done in main. You must use a multi-file format. Implement your code using separate header and c++ files for the functions. I.e., all functions can declared and coded using one .h and one .cpp file. Files: main.cpp Recur_Fun.h Recur_Fun.cpp

Comments in the code should explain how your recursion works. Recursive functions to implement:

[R] str_rev returns the reverse of the argument string. Parameter is passed by reference and constant. Input the string from the console.

[P] palin returns a Boolean indicating whether or not the argument string is a palindrome. Parameter is constant passed by value. Input the string.

[F] find_sub returns a Boolean indicating if the first argument string is a substring of the second. That is, the first argument occurs anywhere in the second. E.g., "to", "day, "oda", are all substrings of "today". Also, "today" would be considered a substring of itself. Parameters are constant pass by reference. Input the substring to find followed by the string to search.

[M] list_max returns the max of a non-negative, integer vector passed by reference and may be changed by function if needed. Input the integers. End with a negative value (do not include the negative value in the list). This recursive implementation can be tricky. Some thoughts. Base case is one element in the vector. Otherwise, return the max(list(0), list_max(tail(list))). tail(list) is the list with list(0) removed. You can also do the same thing by starting at the end of the list instead of the beginning, which would be more efficient.

[E] Not a function but is the command to end the program

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

=+ Why have these changes occurred?

Answered: 1 week ago

Question

=+90 percent of all oil refineries) into several smaller companies

Answered: 1 week ago