An algorithm is made up of 2 modules M1&M2. If order of M1 is f(n) & M2 is g(n) then the order of algorithm is?
A. | max (f(n),g(n)) |
B. | min (f(n),g(n)) |
C. | f(n) + g(n) |
D. | f(n) X g(n) |
Option: B Explanation : |
An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed?
A. | At least 2n-c comparisons, for some constant c, are needed. |
B. | At most 1.5n-2 comparisons are needed. |
C. | At least nlog_{2}n comparisons are needed. |
D. | None of the above. |
Option: B Explanation : |
The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is
A. | Θ(n) |
B. | Θ(logn) |
C. | Θ(log*n) |
D. | Θ(1) |
Option: B Explanation : Since it is a sorted array, we can use binary search to identify the position of the first occurence of the given integer in (logn) steps. If at all this integer repeats, its appearance has to be continuous because the array is sorted. |
Syllabus covered in this section is-
This Section covers Data Structures Questions Answers using C language .
Who can benefit -
Various Search Terms used for this section are