Date: Wednesday, March 5, 2025.
Due Date:Wednesday, March 12, 2025.
In this homework, we'll continue working with the C++ language. The focus of this homework is the tail recursive transformation to iterative, as well as from a non-tail recursive function to a tail recursive one.
Convert the following tail recursive function to iterative:
int sequence1(int n) { if (n < 5) return n; else if (n % 2 == 0) return sequence1(n/2); else return sequence1((n-1)/2); }
Convert the following recursive function to tail recursive:
int sequence2(int n) { if (n < 4) return n/2; else return 3 * sequence2(n-1);
Upload to Canvas, Assignments, Class Exercise 2, a file containing the solution, or just the text of the solution as the submission entry. Add a comment mentioning all the people in the team. One submission per team is sufficient. Students in online sections can submit this individually.