Question
In this, we will write two recursive methods and two iterative methods to solve two problems. The first problem is the sum of squares. Your
In this, we will write two recursive methods and two iterative methods to solve two problems.
The first problem is the sum of squares. Your methods to solve this problem should have one parameter called k of type int. It should return the sum of the squares of the numbers up to and including k (i.e. it should return 1*1 + 2*2 + ... + k*k).
The second problem is checking if a string is a palindrome. It should have one parameter called str of type String. It should return true if the string is palindrome or false otherwise. For example:
Was it a car or a cat I saw? >>>>>>> A palindrome
A toy for a jar of tuna. >>>>>>>> Not a palindrome
Compare the running time of each different implementation of these methods and report your finding based on your observations. Use more data gradually and report if you see differences in the running time by timing your methods executions. You can use a table as follows:
Experiment | Palindrome | String Size | Iterative Palindrome | Recursive Palindrome |
1 | True | |||
2 | False | |||
. | ||||
N |
What to submit?
Two C++ classes, one for each problem. A write up of one page maximum; describing your experiments and results findings.
PLEASE READ THE PROBLEM CAREFULLY!!! I ONLY NEED HELP WITH THE CODING PART, NOTHING ELSE!!! PLEASE ANSWER IN C++!! WHOEVER ANSWERS THIS THANK YOU!!!
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