Top MCQs on Divide and Conquer Algorithm with Answers
Question 1
Question 2
Question 3
Question 4
Question 5
The secant method is used to find the root of an equation f(x) = 0. It is started from two distinct estimates x
a
and x
b
for the root. It is an iterative procedure involving linear interpolation to a root. The iteration stops if f(x
b
) is very small and then x
b
is the solution. The procedure is given below. Observe that there is an expression which is missing and is marked by? Which is the suitable expression that is to be put in place of? So that it follows all steps of the secant method?
Secant
Initialize: xa, xb, ε, N // ε = convergence indicator
fb = f(xb) i = 0
while (i < N and |fb| > ε) do
i = i + 1 // update counter
xt = ? // missing expression for
// intermediate value
xa = xb // reset xa
xb = xt // reset xb
fb = f(xb) // function value at new xb
end while
if |fb| > ε
then // loop is terminated with i = N
write “Non-convergence”
else
write “return xb”
end if
xb – (fb– f(xa)) fb/ (xb – xa)
xa– (fa– f(xa)) fa/ (xb – xa)
xb – (fb – xa) fb/ (xb – fb(xa)
xa – (xb – xa) fa/ (fb – f(xa))
Question 6
Question 7
Consider the following array.
Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?
Question 8
A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is smaller than the maximum element in T?
Θ(nlogn)
Θ(n)
Θ(logn)
Θ(1)
Question 9
int partition (int a[], int n);The function treats the first element of a[] as a pivot, and rearranges the array so that all elements less than or equal to the pivot is in the left part of the array, and all elements greater than the pivot is in the right part. In addition, it moves the pivot so that the pivot is the last element of the left part. The return value is the number of elements in the left part. The following partially given function in the C programming language is used to find the kth smallest element in an array a[ ] of size n using the partition function. We assume k ≤ n
int kth_smallest (int a[], int n, int k)
{
int left_end = partition (a, n);
if (left_end+1==k)
{
return a [left_end];
}
if (left_end+1 > k)
{
return kth_smallest (____________________);
}
else
{
return kth_smallest (____________________);
}
}
Question 10
Let P be an array containing n integers. Let t be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of n elements. Which one of the following choices is correct?
t>2n−2
t>3⌈n/2⌉ and t≤2n−2
t>n and t≤3⌈n/2⌉
t>⌈log2(n)⌉ and t≤n
There are 13 questions to complete.