CSC324H5 Lecture Notes - Lecture 3: Tail Call

49 views2 pages
21 Sep 2017
School
Course
Professor

Document Summary

Recursion (void) means no return value (begin allows to produce multiple items at a time) When we do a recursive call we have have that function added to the frame. If you use tail recursion we can prevent stack over flow as the memory will just remember the last value. We take this property of racket to go from non-tail to tail recursion for both performance and safety reasons. If we recall the example from last class extract-numbers. We use accumulators to return the numbers in the list. Our base case is to return accumulator else we do the recurivse call (tail recursion) Our helper function takes 2 arguments, the list and accumulator. To make it more clear the [] brackets are just for organization purposes. We know when a function creates a new frame during recursion call when the output has mutliple stacked >> As a result we know that a new frame has been created.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents