Consider the expression T & F | T. What is the number of ways in which the expression can be parenthesized so that the output is T (true)?
0
1
2
3
157 practice sets · Page 6 of 8
Consider the expression T & F | T. What is the number of ways in which the expression can be parenthesized so that the output is T (true)?
0
1
2
3
You are given a boolean expression which consists of operators &, | and ∧ (AND, OR and XOR) and symbols T or F (true or false). You have to find the number of ways in which the symbols can be parenthesized so that the expression evaluates to true. This is the boolean parenthesization problem. Which of the following methods can be used to solve the problem?
Dynamic programming
Recursion
Brute force
Dynamic programming, Recursion and Brute force
You are given infinite coins of denominations 3, 5, 7. Which of the following sum CANNOT be achieved using these coins?
15
16
17
4
You are given infinite coins of denominations 5, 7, 9. Which of the following sum CANNOT be achieved using these coins?
50
21
13
23
You are given infinite coins of denominations 1, 3, 4. What is the minimum number of coins required to achieve a sum of 7?
1
2
3
4
You are given infinite coins of denominations 1, 3, 4. What is the total number of ways in which a sum of 7 can be achieved using these coins if the order of the coins is not important?
4
3
5
6
Suppose you are given infinite coins of N denominations v1, v2, v3,.....,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. What is the space complexity of a dynamic programming implementation used to solve the coin change problem?
O(N)
O(S)
O(N^{2})
O(S*N)
You are given infinite coins of N denominations v1, v2, v3,.....,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. What is the time complexity of a dynamic programming implementation used to solve the coin change problem?
O(N)
O(S)
O(N^{2})
O(S*N)
Suppose you have coins of denominations 1,3 and 4. You use a greedy algorithm, in which you choose the largest denomination coin which is not greater than the remaining sum. For which of the following sums, will the algorithm produce an optimal answer?
14
10
6
100
Suppose you have coins of denominations 1, 3 and 4. You use a greedy algorithm, in which you choose the largest denomination coin which is not greater than the remaining sum. For which of the following sums, will the algorithm NOT produce an optimal answer?
20
12
6
5
You are given infinite coins of denominations v1, v2, v3,.....,vn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. This problem can be solved using ____________
Greedy algorithm
Dynamic programming
Divide and conquer
Backtracking
What is the sum of each of the balanced partitions for the array {5, 6, 7, 10, 3, 1}?
16
32
0
64
Which of the following lines should be inserted to complete the above code?
ans[i - arr[j - 1]][j - 1]
ans[i][j]
ans[i][j] || ans[i - arr[j - 1]][j - 1]
ans[i][j] && ans[i - arr[j - 1]][j - 1]
Consider a variation of the balanced partition problem in which we find two subsets such that |S1 - S2| is minimum. Consider the array {1, 2, 3, 4, 5}. Which of the following pairs of subsets is an optimal solution for the above problem?
{5, 4} & {3, 2, 1}
{5} & {4, 3, 2, 1}
{4, 2} & {5, 3, 1}
{5, 3} & {4, 2, 1}
What is the time complexity of the brute force algorithm used to solve the balanced partition problem?
O(1)
O(n)
O(n^{2})
O(2^{n})
In which of the following cases, it is not possible to have two subsets with equal sum?
When the number of elements is odd
When the number of elements is even
When the sum of elements is odd
When the sum of elements is even
Given an array, check if the array can be divided into two subsets such that the sum of elements of the two subsets is equal. This is the balanced partition problem. Which of the following methods can be used to solve the balanced partition problem?
Dynamic programming
Recursion
Brute force
Dynamic programming, Recursion, Brute force
What is the space complexity of the above dynamic programming implementation of the assembly line scheduling problem?
O(1)
O(n)
O(n^{2})
O(n^{3})
What is the time complexity of the above dynamic programming implementation of the assembly line scheduling problem?
O(1)
O(n)
O(n^{2})
O(n^{3})
Which of the following lines should be inserted to complete the above code?
(t2[i] = get_min(t2[i-1]+spent[1][i], t1[i-1]+reach[0][i-1]+spent[1][i]))
(t2[i] = get_min(t2[i-1]+spent[1][i], t1[i-1]+spent[1][i]))
(t2[i] = get_min(t2[i-1]+spent[1][i], t1[i-1]+reach[0][i-1]))
none of the mentioned