Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Recursion question

  • 18-04-2012 5:02pm
    #1
    Registered Users, Registered Users 2 Posts: 1,645 ✭✭✭


    Probably a simple question, would this method be described as a recursive method.?

    It's just a sorting method for a heap I am doing in college. For some reason I am hesitant to say it is even though it obviously calls itself within the code. Feels slightly different from the other recursive functions I would have looked at like Fibonacci and Factorial.
       private void bubbleUp(int index ) {
            if( index > 0 ) {
                int parentNode = ( index - 1 ) / 2;
                if( array[ parentNode ] > array[ index ] ) {
                    swap( parentNode, index );
                    bubbleUp( parentNode );
                }
            }
        }
    


Comments

  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Yes.


  • Registered Users, Registered Users 2 Posts: 1,645 ✭✭✭k.p.h


    Thanks, so the definition of a recursive function is just a function that calls itself. That simple ..?


  • Registered Users, Registered Users 2 Posts: 5,015 ✭✭✭Ludo


    Google "recursion"...silly software engineering humour :-)


  • Registered Users, Registered Users 2 Posts: 1,645 ✭✭✭k.p.h


    Yeah I'v done the google ;) quite a bit about recursion online,lot of different types and a broad subject IMO. What I was wondering about was it incorrect to refer to any method that calls itself under the term "recursion" in exam situations etc. Seems like it's OK anyway. Thanks for the help.


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    And the most common use of recursion is the type you're not used to! Using it to walk data structures on the other hand is common as hell!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,645 ✭✭✭k.p.h


    Ludo wrote: »
    Google "recursion"...silly software engineering humour :-)

    Ah I see :p


Advertisement