Question: 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
Get step-by-step solutions from verified subject matter experts
