logo

Crowdly

Browser

Додати до Chrome

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на ilearn.mq.edu.au?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome