Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need a recursive version of this iterative method. don\'t use variables not li

ID: 3567441 • Letter: I

Question

I need a recursive version of this iterative method.
don't use variables not listed here.
the reheapDown algorithm repeatedly falls newHole to find the next index for the hole, and then moves the hole down to that location. it does this until newHole returns the same index that is passed to it.
here's the code for reheapDown

private void reheapDown(T element)
//current root postion is "empty";
//Inserts element into the tree and ensures shape and order properties.
{
   int hole = 0; // current index of hole
   ing newhole ; // index where hold should move to

   newhole = newHole(hole, element); //find next hole
   while (newhole != hole)
   {
//move to element up       elements.set(hole,elements.get(newhole));    
      hole = newhole; //move hold down
      newhole = newHole(hole, element); //find next hole
}

elements.set(hole, element); //fill in the final hole
}

Explanation / Answer

private void reheapDown(T element)
{
int static hole = 0; // current index of hole
int newhole ; // index where hold should move to

newhole = newHole(hole, element); //find next hole

   if(newhole == hole)//base condition
   {
        elements.set(hole, element); //fill in the final hole
       return;
   }

   elements.set(hole,elements.get(newhole));
   hole = newhole; //move hold down

   reheapDown(element);

  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote