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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:56:24+00:00 2026-05-14T08:56:24+00:00

My slides say that: A recursive call should always be on a smaller data

  • 0

My slides say that:

  • A recursive call should always be on a smaller data structure than the current one

  • There must be a non recursive option if the data structure is too small

  • You need a wrapper method to make the recursive method accessible

Just reading this from the slides makes no sense, especially seeing as it was a topic from before christmas!

Could anyone try and clear up what it means please?

Thank you

  • 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-14T08:56:24+00:00Added an answer on May 14, 2026 at 8:56 am

    A recurssive call should always be on a smaller data structure than the current one

    In general this isn’t true but if you are talking about linked lists manipulation with recursion it is. What it is implying is that you need to always be working towards a solution and this usually is dealing with a smaller problem than you started with.

    Take for example Quicksort. Each time the function is called it is working with a smaller set of data.

    Taking another example of printing a linked list, the next time you call the recursive function the argument should be the tail of the linked list (This code has an error in it, but that leads us to our next point)

    void printList(List l){
        print(l.head);
        printList(l.tail); 
    }
    

    There must be a non recurssive option if the data structure is too small

    This means there should be a base case. The point where the function stops calling itself again.

    int factorial(int n){
        if ( n == 1 ){ //the base case is when n = 1
            return 1;
        }
        return n*factorial(n-1);
    }
    

    Going back to the example of printing a linked list, there has to be a case where you only have an empty list left (in which case the function should do nothing). Going back to the code to print a linked list

    void printList(List l){
        if ( l.empty == true ){ //the base case is when the list l is empty
            return;
        }
    
        print(l.head);
        printList(l.tail); 
    }
    

    You need a wrapper method to make the recurssive method accessible

    I don’t know Java, and it isn’t really a language designed for recursion, however in many cases your recursive function will have more parameters than the person using the API should be able to see. You might for example want to have a counter in there.

    You can have a wrapper function that simplifies the parameters to just what is needed. The wrapper function then calls the real worker function.

    An example might be if we have a linked list class that has the recursive function to print the list. Its declaration would look something like this:

    void printList(List l);
    

    However as it is a class method, to someone using the API it doesn’t make much sence to have to do this:

    myList.printList(myList);
    

    So a wrapper function could be created that doesn’t have any paramters which then calls the code that does the work.

    void printList(){
         doPrintList(this); //pass in the List object as the first argument
    }
    

    Then all the programmer using the API has to do is:

    myList.printList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML and jQuery that slides a div up and down to
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
I need to create a custom volume slider for a WMP object. The current
How do I make one jquery ui slider control another? If I slide slider
I want to style the slider control so that the height of the draggable
I am writing both sides of an ASP-webpage to ASP-webpage conversation in which the
Has anyone seen a good twin slider control for .Net (Win forms or WPF).
I want to create a volume slider for my application. I don't mind whether
You may have seen JavaScript sliders before: http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html What I'm envisioning is a circular
I'm talking about the slide to unlock button on iPhone. Any ideas how to

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.