Find the maximum sub-array sum for the given elements. {-2, -1, -3, -4, -1, -2, -1, -5, -4}
-3
5
3
-1
Browse topic-based Data Structure And Algorithm practice sets.
302 practice sets · Page 7 of 16
Find the maximum sub-array sum for the given elements. {-2, -1, -3, -4, -1, -2, -1, -5, -4}
-3
5
3
-1
Find the maximum sub-array sum for the given elements. {2, -1, 3, -4, 1, -2, -1, 5, -4}
3
5
8
6
Given a one-dimensional array of integers, you have to find a sub-array with maximum sum. This is the maximum sub-array sum problem. Which of these methods can be used to solve the problem?
Dynamic programming
Two for loops (naive method)
Divide and conquer
Dynamic programming, naïve method and Divide and conquer methods
Which of the following lines should be inserted to complete the above code?
arr[row][k] - arr[k + 1][col] + mat[row - 1] * mat[k] * mat[col];
arr[row][k] + arr[k + 1][col] - mat[row - 1] * mat[k] * mat[col];
arr[row][k] + arr[k + 1][col] + mat[row - 1] * mat[k] * mat[col];
arr[row][k] - arr[k + 1][col] - mat[row - 1] * mat[k] * mat[col];
Consider the brute force implementation in which we find all the possible ways of multiplying the given set of n matrices. What is the time complexity of this implementation?
O(n!)
O(n^{3})
O(n^{2})
Exponential
Consider the matrices P, Q, R and S which are 20 x 15, 15 x 30, 30 x 5 and 5 x 40 matrices respectively. What is the minimum number of multiplications required to multiply the four matrices?
6050
7500
7750
12000
Consider the matrices P, Q and R which are 10 x 20, 20 x 30 and 30 x 40 matrices respectively. What is the minimum number of multiplications required to multiply the three matrices?
18000
12000
24000
32000
Consider the two matrices P and Q which are 10 x 20 and 20 x 30 matrices respectively. What is the number of multiplications required to multiply the two matrices?
10*20
20*30
10*30
102030
Which of the following is the recurrence relation for the matrix chain multiplication problem where mat[i-1] * mat[i] gives the dimension of the ith matrix?
dp[i,j] = 1 if (i=j dp[i,j] = min{dp[i,k] + dp[k+1,j]})
dp[i,j] = 0 if (i=j dp[i,j] = min{dp[i,k] + dp[k+1,j]})
dp[i,j] = 1 if (i=j dp[i,j] = min{dp[i,k] + dp[k+1,j]} + mat[i-1]*mat[k]*mat[j]).
dp[i,j] = 0 if (i=j dp[i,j] = min{dp[i,k] + dp[k+1,j]} + mat[i-1]*mat[k]*mat[j]).
Which of the following methods can be used to solve the matrix chain multiplication problem?
Dynamic programming
Brute force
Recursion
Dynamic Programming, Brute force, Recursion
Which of the following lines completes the above code?
strrev(str2)
str2 = str1
len2 = strlen(str2)
strlen(str2)
Longest palindromic subsequence is an example of ______________
Greedy algorithm
2D dynamic programming
1D dynamic programming
Divide and conquer
For every non-empty string, the length of the longest palindromic subsequence is at least one.
True
False
What is the time complexity of the brute force algorithm used to find the length of the longest palindromic subsequence?
O(1)
O(2^{n})
O(n)
O(n^{2})
What is the length of the longest palindromic subsequence for the string "ababcdabba"?
6
7
8
9
For which of the following, the length of the string is not equal to the length of the longest palindromic subsequence?
A string that is a palindrome
A string of length one
A string that has all the same letters(e.g. aaaaaa)
Some strings of length two
Which of the following is not a palindromic subsequence of the string "ababcdabba"?
abcba
abba
abbbba
adba
Which of the following methods can be used to solve the longest palindromic subsequence problem?
Dynamic programming
Recursion
Brute force
Dynamic programming, Recursion, Brute force
In the brute force implementation to find the longest increasing subsequence, all the subsequences of a given sequence are found. All the increasing subsequences are then selected and the length of the longest subsequence is found. What is the time complexity of this brute force implementation?
O(n)
O(n^{2})
O(n!)
O(2^{n})
The number of increasing subsequences with the longest length for the given sequence are: {10, 9, 8, 7, 6, 5}
3
4
5
6