Skip to content

cs20-lpc/week-6-wed-lab-ProgrammerOps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date Open in Visual Studio Code

Week 6 Wed Lab

Directions

For this lab activity, you are going to practice writing tail recursive functions. The starting code contains five recursive functions that we've studied so far in class. Your job is to refactor the functions to be tail recursive (so yes, you can change the parameter list). Do not rely on the compiler automatically optimizing for you, write the tail recursion yourself. The main function has already been written for you to run test cases.

Creating a tail recursive version of the Fibonacci function is tricky. But if you do it right, it will reduce the time complexity from $\mathcal{O}(2^n)$ to $\mathcal{O}(n)$. Amazing improvement!

Sample Run

The following is what your program should display (quickly!) if you converted all the functions into tail recursion:

6 * 123000 = 738000
3 ^ 10 = 59049
8 * 9 * ... * 15 = 259459200
10! = 3628800
50th Fibonacci number is 3996334433

About

cs20-lpc-classroom-20414-week-6-wed-lab-Week-6-Wed-Lab created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%