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

The Archive Base Latest Questions

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

I am just studying a few classes given to me by my lecturer and

  • 0

I am just studying a few classes given to me by my lecturer and I can’t understand how the function heapRebuild is being made used of! It doesn’t change any global variables and it doesn’t print out anything ad it doesn’t return anything – so should this even work? It shouldn’t, should it?

If you were told to make use of heapRebuild to make a new function removeMac would you edit heapRebuild?

public class MaxHeap<T extends Comparable<T>> implements Heap<T>{
private T[] heap;
private int lastIndex;

public T removeMax(){
        T rootItem = heap[0];
        heap[0] = heap[lastIndex-1];
        lastIndex--;
        heapRebuild(heap, 0, lastIndex);
        return rootItem;
}

protected void heapRebuild(T[ ] items, int root, int size){

        int child = 2*root+1;
        if( child < size){
            int rightChild = child+1;
            if ((rightChild < size) &&
                    (items[rightChild].compareTo(items[child]) > 0)){
                child = rightChild;
            }
            if (items[root].compareTo(items[child]) < 0){
                T temp = items[root];
                items[root] = items[child];
                items[child] = temp;
                heapRebuild(items, child, size);}
        }
    }

}

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

    Java is a pass-reference-by-value OO language. The methods can change the passed-in mutable values.

    Simplified example:

    import java.util.Arrays;
    
    public class Test {
    
        public static void main(String... args) {
            String[] strings = new String[] { "foo", "bar" };
            System.out.println(Arrays.toString(strings)); // [foo, bar]
            changeValue(strings);
            System.out.println(Arrays.toString(strings)); // [foo, foo]
        }
    
        public static void changeValue(String[] strings) {
            strings[1] = "foo";
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just saw this code while studying the wordpress source code (PHP), You can
After studying TCP/UDP difference all week, I just can't decide which to use. I
I'm just studying the Builder pattern and do not understand the point of the
I'm studying B+trees for indexing and I try to understand more than just memorizing
I am just studying other user's PHP code right now to understand and learn
I'm studying some source codes and I'm just wondering why a class (or classes)
I am trying to understand few things about using dylib and still studying, so
I started studying about AppDomains, and I just cannot understand the difference between CreateInstance
Just studying the C style of Jon Bentley's Programming Pearls and was wondering if
I'm just studying Silverlight (in C#) and I got a problem. I have 14

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.