Introduction In this lab you will find several exercises to strengthen your understanding of recursion and C++ arrays. Turn in all your work (code, spreadsheets, graphs, and short answers) into Blackboard. Part 1: Recursion A. Write a recursive function named factorial that computes the factorial for a given int. B. Write a recursive function named fibonacci that computes the value of the nth Fibonacci sequence: [1, 2, 3, 5, ...] C. Write a function named towers that counts the number of moves in Towers of Hanoi given the number of rings n. Part 2: Unit Testing Write test functions for the three functions in part 1. Name your test functions with a "test" prefix; for example, testRecursive Contains. Use the minimal test equivalence class to ensure a minimal yet complete test. Use c-style asserts to verify and validate values or print to the console for manual verification. Part 3: Time Complexity Review Big-O notation in the link provided'. In this exercise we'll explore the time complexity of the recursive Towers of Hanoi solution. Below you'll see a Big-O complexity chart we'll use later containing common ways algorithm operations can scale with user input. The towers function you created outputs the number of moves required for the number of rings given. Use this function to gather several input and output sample points. Enter these points into a spreadsheet program such as Google Sheets or Microsoft Excel. Once you have a dozen or sample points, create a plot like in the Big-O complexity chart.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 17PE
icon
Related questions
Question
Introduction
In this lab you will find several exercises to strengthen your understanding of recursion and
C++ arrays. Turn in all your work (code, spreadsheets, graphs, and short answers) into
Blackboard.
Part 1: Recursion
A. Write a recursive function named factorial that computes the factorial for a given
int.
B. Write a recursive function named fibonacci that computes the value of the nth
Fibonacci sequence: [1, 2, 3, 5, ...]
C. Write a function named towers that counts the number of moves in Towers of Hanoi
given the number of rings n.
Part 2: Unit Testing
Write test functions for the three functions in part 1. Name your test functions with
a "test" prefix; for example, testRecursive Contains. Use the minimal test equivalence
class to ensure a minimal yet complete test. Use c-style asserts to verify and validate
values or print to the console for manual verification.
Part 3: Time Complexity
Review Big-O notation in the link provided'. In this exercise we'll explore the time
complexity of the recursive Towers of Hanoi solution. Below you'll see a Big-O complexity
chart we'll use later containing common ways algorithm operations can scale with user
input.
The towers function you created outputs the number of moves required for the
number of rings given. Use this function to gather several input and output sample points.
Enter these points into a spreadsheet program such as Google Sheets or Microsoft Excel.
Once you have a dozen or sample points, create a plot like in the Big-O complexity chart.
Transcribed Image Text:Introduction In this lab you will find several exercises to strengthen your understanding of recursion and C++ arrays. Turn in all your work (code, spreadsheets, graphs, and short answers) into Blackboard. Part 1: Recursion A. Write a recursive function named factorial that computes the factorial for a given int. B. Write a recursive function named fibonacci that computes the value of the nth Fibonacci sequence: [1, 2, 3, 5, ...] C. Write a function named towers that counts the number of moves in Towers of Hanoi given the number of rings n. Part 2: Unit Testing Write test functions for the three functions in part 1. Name your test functions with a "test" prefix; for example, testRecursive Contains. Use the minimal test equivalence class to ensure a minimal yet complete test. Use c-style asserts to verify and validate values or print to the console for manual verification. Part 3: Time Complexity Review Big-O notation in the link provided'. In this exercise we'll explore the time complexity of the recursive Towers of Hanoi solution. Below you'll see a Big-O complexity chart we'll use later containing common ways algorithm operations can scale with user input. The towers function you created outputs the number of moves required for the number of rings given. Use this function to gather several input and output sample points. Enter these points into a spreadsheet program such as Google Sheets or Microsoft Excel. Once you have a dozen or sample points, create a plot like in the Big-O complexity chart.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning