Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the running time for these methods? 1- public static void m4(int[] arr) { for (int i=0; i System.out.println(arr[i] * 10); } for (int

What is the running time for these methods?

1-

public static void m4(int[] arr) {

for (int i=0; i

System.out.println(arr[i] * 10); }

for (int j=arr.length-1; j>=0; j--) {

System.out.println(arr[j] / 10); }

}

2-

public static void m5(int[] arr) {

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

for (int j=0; j

System.out.println(Math.max(arr[i],

arr[j])); }}

}

3-

public static int mystery(int n) {

int count = 0;

int cur = 1;

while (cur < n) {

count++;

cur = cur * 2;

}

return cur;

}

4-

int pow(int m, int n) {

int ret = 1;

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

ret *= m;

}

return ret;

}

5-

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;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago

Question

3. You can gain power by making others feel important.

Answered: 1 week ago