Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

State the approximate worst-case running time for each of the following. If you are unsure of one of the calls into the Java Platform APIs,

State the approximate worst-case running time for each of the following. If you are unsure of one of the calls into the Java Platform APIs, think about how the method might be implemented, and/or read its documentation.

Appropriate answers are of the form constant time or [X] in [Y], where [X] might be linear, quadratic, or the like, and [Y] is the name of the variable or quantity in question. For example, a traversal of an array is linear in the length of the array; if the array is named a, it is linear in a.length.

A. void reverse(int[] a) {

for (int front = 0; front < a.length / 2; front++) {

int rear = a.length - 1 - front;

int t = a[front];

a[front] = a[rear];

a[rear] = t; } }

B.int allPairsProductSum(int[] a) {

int result = 0; for (int i: a) {

for (int j: a) {

result += i * j;} }

 return result;}

C. ArrayList(Collection c) (that is, the copy constructor for ArrayList)

D. ArrayList.size

E. Arrays.binarySearch (Hint: maybe Google for binary search

please answer the question in the correct form Thank you!!!!!

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago

Question

Introduce and define metals and nonmetals and explain with examples

Answered: 1 week ago

Question

6. What is process reengineering? Why is it relevant to training?

Answered: 1 week ago