Skip to main content

Questions tagged [tail-recursion]

1 vote
0 answers
112 views

Consider a singly recursive function $f$, which, say, has the following form: ...
Bruno's user avatar
  • 346
4 votes
1 answer
274 views

I am struggling to wrap my head around this compiler technique, so let's say here's my factorial function ...
hello world's user avatar
0 votes
1 answer
96 views

I need to prove: reverse(push(as,bs)) = push(reverse(bs), reverse(as)) where: ...
darkshadowx's user avatar
13 votes
4 answers
5k views

There is the axiom you should always prefer tail-recursion over regular recursion whenever possible. (I'm not considering tabulation as an alternative in this question). I understand the idea by why ...
AmandaSai98b's user avatar
2 votes
1 answer
57 views

For example exist linked list with thousands (maybe million) elements or very deep tree which some branches are very long and have only one child, but exists other short branches with many children. ...
Saku's user avatar
  • 141
3 votes
1 answer
262 views

When researching how to optimize recursion into loops, I came upon (on Wikipedia) a general rule about this: Whenever a function is in form: ...
lav_shaun's user avatar
0 votes
0 answers
141 views

Are some algorithms inherently recursive? As in, rewriting it in tail-recursive/iterative form with a stack is still needed, and there is no way to do it otherwise. I am asking because I struggled to ...
blitzqwe's user avatar
  • 125
3 votes
1 answer
662 views

I am doing some exercises on dynamic programming in order to get familar with this concept. I've noticed that most of the time it's not difficult to calculate the complexity of a program using dynamic ...
DP_q's user avatar
  • 31
16 votes
2 answers
2k views

I'm familiar with the idea of basic tail recursion elimination, where functions that return the direct result of a call to themselves can be rewritten as iterative loops. ...
Maxpm's user avatar
  • 263
-1 votes
1 answer
4k views

CLRS Problem : 7.4 How does Tail-Recursive-QuickSort improve the efficiency of quick sort any better ? Original quicksort Tail recursive quicksort Question ...
Sagar's user avatar
  • 101
1 vote
2 answers
540 views

I'm rather confused by the recursion theory. From the link, the recursion theory was formed by Dedekind, Gödel and some other famous mathematicians. There are the following types of recursion. But ...
user3329081's user avatar
6 votes
1 answer
395 views

How can the class of tail recursive functions (TR) be compared to the classes of primitive recursive functions (PR) and recursive functions (R)? The computation of a PR function always halts. This ...
Peter's user avatar
  • 361