Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2 Run-Time // This method returns whether or not a pair of numbers, // num1 and num2, are between 1-m and 1-n, respectively boolean findPair(int

Q2 Run-Time

// This method returns whether or not a pair of numbers,

// num1 and num2, are between 1-m and 1-n,

respectively boolean findPair(int num1, int num2, int m, int n) {

for (int i = 1; i <= m; i++) {

if (num1 == i) {

for (int j = 1; j <= n; j++) {

if (num2 == j) {

return true;

} } } }

return false; }

Q2.1 Worst Case Runtime

What is the worst case runtime of findPair?

A. O(m+n)

B. O(m*n)

C. O(m/n)

D. O(m)

E. O(n)

Q2.2 Best Case Runtime

What is the best case runtime of findPair given it returns false?

A. O(1)

B. O(m+n)

C. O(m*n)

D. O(m)

E. O(n)

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_2

Step: 3

blur-text-image_3

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

Students also viewed these Databases questions