Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is in C++ (please clarify how where to include the functions in .h and .cpp etc) Coding exercise 1 Analyze the file lucas.cpp provided

image text in transcribedimage text in transcribed

image text in transcribed

this is in C++ (please clarify how where to include the functions in .h and .cpp etc)

Coding exercise 1 Analyze the file lucas.cpp provided in the assignment. It contains a recursive function to compute the nth Lucas number Using a Linux environment or your IDE, debug through the code2 in gdb3 to understand in what order the function lucas is called and with what parameters. In a file called Lucas.txt, list the function calls and returns in the order in which they were made when n7. Eg., when n-4, the list of function calls and returns is 1. Call lucas(4) 2. Call lucas(3) 3. Call lucas(2) 4. Returning 1 from lucas(2) 5. Call lucas(1) 6. Returning 2 from lucas(1) 7. Returning 3 from lucas(3) 8. Call lucas(2) 9. Returning 1 from lucas(2) 10. Returning 4 from lucas(4) Coding exercise 2 In a file called palindrome.txt, write the pseudocode to recursively check if a string is a palindrome or not. A palindrome is a string that reads the same backwards and forwards. E.g., racecar. In your implementation, you may assume that there are no spaces in the input string Once you have the pseudocode, write a function bool check_palindrome (const string &s) in a file called palindrome.cpp that implements the recursive algorithm you have written. Determine the computational complexity of your code and report it in palindrome.txt. Coding exercise 3 Extend your implementation of the arrayList template from Lab 3 to include a function called elemType getMin( that finds the smallest element in a list. Implement this function using recursion. Lucas txt #include using namespace std; unsigned int lucas(unsigned int n)f if(n0) throw "No Oth Lucas Number"; if(n = 1){ return 2; if(n = 2){ return 1; return lucas(n-1)+ lucas(n-2); int main() unsigned int n = 7; cout

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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Explain why many households do not participate in the stock market.

Answered: 1 week ago