Lam Pham
1 min readSep 11, 2020

--

tks Alfred. In fact, tail-recursive function is only another style of recursion. You can say it equivalent to a looping, ok some how acceptable, but it does not resolve stackoverflow error because Stack still needs to store frame f(n) and wait for f(n -1). In term of memory, tail-recursive function is not different from normal recursion.

You can try it by making a factorial() function, debug it and look at the Frames tab, you will see all the frames from f(n) down to f(1) are stored in stack

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Lam Pham
Lam Pham

Responses (1)

Write a response