logo

Crowdly

Browser

Додати до Chrome

COMP2010 Algorithms and Data Structures / COMP6011

Шукаєте відповіді та рішення тестів для COMP2010 Algorithms and Data Structures / COMP6011? Перегляньте нашу велику колекцію перевірених відповідей для COMP2010 Algorithms and Data Structures / COMP6011 в ilearn.mq.edu.au.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

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%
Переглянути це питання
For this question the hashtable setup, operations, and values are the same as in Question 9; the only difference is that there is quadratic probing rather than linear probing, and your table size (and consequent hash function) may be different.

In this question, you are working with table size TSize=14.  At what array index does the value 38 get inserted?

0%
0%
0%
0%
Переглянути це питання

Given the following code to compute "n to the power of x"

 

static int fastPower(int n, int x){

int a= x; int b= 1; int i= n;

while(i>0) {

if (i%2==0){

a= a*a;

i= i/2;

}

else {

b= a*b;

i= i-1;

}

}

return b;

}

Which of the following logical statements is a valid and useful invariant for proving this code does actually compute n to the power of x?

0%
0%
0%
0%
0%
Переглянути це питання

Which is an post-order traversal of the following tree

t

/ \

h a

/ \ / \

n k s k

/ \ / \ / \ / \

i v e r y m u c

/ /

h s

/ \

k i

0%
0%
0%
0%
Переглянути це питання

Which is an breadthfirst traversal of the following tree?

t

/ \

h a

/ \ / \

n k s k

/ \ / \ / \ / \

i v e r y m u c

/ /

h s

/ \

k i

0%
0%
0%
0%
Переглянути це питання
You carry out the following operations on an empty hash table of size TSize=12:

(a) insert 26, 10, 12, 102, 39, 40; then

(b) delete 39; then

(c) insert 15, 38.

For hashing, use the hash function h(K) = K mod TSize, and linear probing with p(i) = i (i.e. step size 1).

At what array index does the value 38 get inserted?

0%
0%
0%
100%
Переглянути це питання

Each of the following code snippets finds the value target in a sorted list lst.  Which is using divide and conquer?  If you spot any errrors in the code, ignore them and answer for a corrected version of that snippet.

0%
0%
0%
100%
Переглянути це питання

What line of code at line XXXXX will result in ThisData being a recursive data type?

class ThisData{

    XXXXX

    int value;

}

0%
0%
0%
0%
0%
Переглянути це питання

Which of the following numerical sequences is ameanable to dynamic programming?  I.e. which could be significanlty sped up by applying dynamic programming to the programming of an algorithm to compute each value in the sequence?  You may assume for all that

m(0) = 0

m(1) = 1

m(2) = 2

50%
0%
0%
50%
Переглянути це питання

Which of the following definitions of recursive data is most correct? 

0%
0%
0%
0%
0%
0%
Переглянути це питання

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

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

Browser

Додати до Chrome