Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:42:36+00:00 2026-06-08T20:42:36+00:00

Possible Duplicate: Are there problems that cannot be written using tail recursion? From my

  • 0

Possible Duplicate:
Are there problems that cannot be written using tail recursion?

From my understanding, tail recursion is an optimization you can use when a recursive call does not need information from the recursive calls that it will spam.

Is it possible then to implement all recursive functions using tail-recursion? What about something like DFS, where you need the innermost child to return before the parent can?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:42:37+00:00Added an answer on June 8, 2026 at 8:42 pm

    It depends on exactly what you are asking.

    If you want to keep all functions as functions (no mutable state) with the same signatures, then no. The most obvious example is the quicksort, where both calls can’t be tail calls.

    If you can modify the function in various ways, then yes. Sometimes a local modification is sufficient – often you can add an “accumulator” that builds some expression that is returned, although, if the result involves non-commutative operations, then you need to be careful (for example, when naively constructing linked lists, the order is reversed) or you can add a stack.

    Alternatively, you can do a global modification of the entire program, in which each function takes as an extra argument the function that contains future actions. This is the continuation passing that Pete is talking about.

    if you are working by hand then the local modification is often fairly easy. but if you’re doing automated rewriting (in a compiler for example) then it’s simpler to take the global approach (it requires less “smarts”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can every recursion be converted into iteration? Are there problems in which
Possible Duplicate: Is there a standard date/time format that can be passed on a
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Possible Duplicates: Is there a problem that has only a recursive solution? Can every
Possible Duplicate: Is there a CSS parent selector? CSS selector for “foo that contains
Possible Duplicate: Why there is not a comprehensive c archive network? Everyone knows that
Possible Duplicate: Get just the hour of day from DateTime using either 12 or
Possible Duplicate: Are there any disadvantages to always using nvarchar(MAX)? Is there a general
Possible Duplicate: Is there a proved mouseOver workaround for FirefoxDriver in Selenium2? I want
Possible Duplicate: Is there any hash function in PL/SQL? I have a column with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.