Β solve computer science 2 question
Show that 8π β 5π + 7 = π(π )
Determine whether each of these functions is bounded by O(n). Say yes or no.
π(π) = 3a)
π(π) = π + π + 12b)
π(π) = βπβc)
π(π) = 17π + 7d)
π(π) = 15π log πe)
π(π) =
π
2
f)
Exam 1 Review
Friday, January 26, 2024 7:14 AM
Arrange the following functions in ascending order of growth rate.
Solve the following recurrences using Master Theorem.
π(π) = 16π
π
4
+ πβπ
π (π) = 1.5 + 50
π (π) = π + π log π
π (π) = (log π)
π (π) = βπ log π
π (π) = 10
π (π) = π + π
π (π) = (π!)
π(π) = π
π
5
+ 10
In the divide and conquer closest pair of points, we sorted the coordinates
(x or y). Once sorted, are we ready to start computing distances?
Given a positive number π, find all combinations of 2π elements such that
every element from 1 to π appears exactly twice and the distance
between its two appearances is equal to the value of the element.
Complete the following a backtracking algorithm (findAllComboR) in Java.
Example:
n = 3
Output: 3 1 2 1 3 2
2 3 1 2 1 3
n = 4
Output: 4 1 3 1 2 4 3 2
2 3 4 2 1 3 1 4
public static void findAllCombo(int n)
{
int[] arr = new int[2*n];
Arrays.fill(arr, -1);
findAllComboR(arr, 1, n);
}
public static void findAllComboR(int[] arr, int x, int n)
{
}
Complete the backtracking algorithm in Java (printComboR) to print all possible
combinations of numbers 1 and π having the sum π. Assume π is a positive
integer.
Example: n = 5
[5]
[1,4]
[2,3]
public static void printComboR(int i, int n, int[] A, int index)
{
}
public static void printCombo(int n)
{
int [] A = new int[n];
printComboR(1, n, A, 0);
}