logo

Crowdly

Browser

Add to Chrome

You have the following two functions anonFnA() and anonFnB() added to the Heap c...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

You have the following two functions anonFnA() and anonFnB() added to the Heap class from lectures.

    public int anonFnA() {

      return anonFnB(0);

    }

    private int anonFnB(int root) {

        int leftChild = 2 * root + 1;

        int rightChild = leftChild + 1;

        int count = 0;

        if (size == 0)

            return 0;

        if ((leftChild < size) && (items[leftChild] == items[root]))

            count += anonFnB(leftChild);

        if ((rightChild < size) && (items[rightChild] == items[root]))

            count += anonFnB(rightChild);

        return 1 + count;

    }

You apply it to the heap that, in array form, contains the values 24, 24, 24, 10, 15, 24, 8, 9, 8, 15, 14 (i.e. these are stored in array items at indices 0, . . . , 10). What is the value of function anonFnA()?

0%
0%
100%
0%
More questions like this

Want instant access to all verified answers on ilearn.mq.edu.au?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome