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 6779117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:50+00:00 2026-05-26T16:20:50+00:00

I’ve been doing problems on recursion in my Data Structures & Algorithms class and

  • 0

I’ve been doing problems on recursion in my Data Structures & Algorithms class and for some tail-recursive functions I couldn’t think of doing anything but having the main function call a helper function and the helper function being the tail recursive part since I had to pass different parameters than the original function.

While this is technically tail-recursive the original function is the one that ends up handling the base cases and in the main case passes the additional parameters to the actual tail recursive function.

Obviously this sort of defeats the idea of recursion, especially in a class setting for homework, exams and such.

That’s why today I thought, instead of making a helper function, couldn’t I make an overloaded version of the function that accepts those additional parameters and continues the work? It would technically be recursive since all the calls in the function are to itself, albeit with more parameters than the initial call.

Here’s a rough example:

int fibonacci(int n) {
    if (n == 1)
        return 1;
    else
        return fibonacci(n, 2, 1, 2);
}

int fibonacci(int n, int f1, int f2, int c) {
    if (c == n)
        return f1;
    else
        return fibonacci(n, f1 + f2, f1, c + 1);
}

Is it still recursion in the definition sense? Would it work? Would the compilers that do recursion optimization (don’t know how it works exactly, but know it exists) apply that to this?

I assume that it’s still recursion since it’s technically calling itself still and I would think it would optimize, just ignoring the initial call. But that’s why I’m asking, to see if I’m right or not.

  • 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-05-26T16:20:50+00:00Added an answer on May 26, 2026 at 4:20 pm

    Yes, I would still call this “recursion.” The one-argument overload of fibonacci is not recursive, but the 4-argument overload is recursive without a doubt.

    That said: don’t fool yourself into thinking that the fibonacci function overall is recursive. The one-argument overload never calls itself. In Java-like languages, where a function/method is uniquely defined by its signature, you still have two distinct functions.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.