CP164 Lecture Notes - Lecture 11: Everytime

24 views2 pages
School
Course
Professor

Document Summary

Has to make a decision to continue recursion. Turns out to be efficient but elegant way of solving certain types of problems. Etc with binary trees we can"t just write a loop. Implies function returns something ( values or multiple values. Everytime recursion occurs there are multiple copies of functions ( in this case reverse_list) but then goes away when it is done executing. Important to stop ( or we will get infinite recursion) because it takes up memory in python. Reverse stack stacking all the calls of the functions and start popping all those function calls. Data[1:n-1]=revlist_f(data[1:n-1])---> replaces with copy we want from recursions. Base case when we do not recurse ( stops calling itself) in this case when n=1. Only difference is that fruitful makes a copy of list while inplace did not. The aux function is a helper function and in recursion the helper function is a function that does extra work.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents