logo

Crowdly

Browser

Add to Chrome

COMP2010 Algorithms and Data Structures / COMP6011

Looking for COMP2010 Algorithms and Data Structures / COMP6011 test answers and solutions? Browse our comprehensive collection of verified answers for COMP2010 Algorithms and Data Structures / COMP6011 at ilearn.mq.edu.au.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

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%
View this question
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%
View this question

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%
View this question

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%
View this question

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%
View this question
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%
View this question

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%
View this question

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%
View this question

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%
View this question

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

0%
0%
0%
0%
0%
0%
View this question

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