Question: Help the java exersice !! 1. Each of the below methods determine m, n without using Math.pow. Using big-O notation in terms of n, how

Help the java exersice !!

1. Each of the below methods determine m, n without using Math.pow. Using big-O notation in terms of n, how much time does each take?

a.

int pow(int m, int n) {

int ret = 1;

for (int i = 0; i < n; i++) {

ret *= m;

}

return ret;

}

b.

int pow(int m, int n) {

int ret = 1;

int k = m;

int i = n;

while (i > 0) {

if (i % 2 == 1) ret *= k;

k *= k;

i /= 2;

}

return ret;

2. Draw the tree state of a min-heap after adding these elements. You should draw the tree step by step. (3,2,6,1,5,4)

Draw the tree state of a min-heap after eliminating only one root node (not all of them). You should draw the tree step by step.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!