Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Jeremy Ashcraft13,887 Points
each recursive call is put in memory on the stack, why do we not factor this into the space complexity calc?
since each recursive call results in a new frame on the stack, thus requiring more memory with each recursive call—why do we not factor in the growing memory requirements caused by recursion when assessing the efficiency of space used in our algorithm?
is the extra memory negligible? is this largely dependant on the language's implementation of recursion? does tail optimization resolve this?
Steven Parker218,653 Points
Each frame does add some space, but it's the same amount for each call. Since the actual quantity of bytes isn't used for the purposes of complexity analysis, the fact that a portion of the total is taken up by the frame doesn't change the complexity factor.