Computer Science EngineeringHardISRO SC (CS)
The worst-case number of key comparisons binary search makes on a sorted array of 100 elements (counting one three-way comparison per probe) is:
- A. 7
- B. 6
- C. 8
- D. 9
Correct answer: A. 7
Worst case = floor(log2 n) + 1 = 7.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- Trace this C function. int f(int n){ if(n==0) return 1; return nf(n-1) - f(n/2); } (integer division) What does f(6) return?
- Using the Master theorem (extended form), the solution of T(n) = 27T(n/3) + n^3 is:
- Using the Master theorem (extended form), the solution of T(n) = 2T(n/3) + n is:
- Consider the following C fragment. int c=0; for(int i=200;i>=1;i/=2) for(int j=0;j<i;j++) c++; What is c at the end? (integer division)
- The worst-case number of key comparisons binary search makes on a sorted array of 127 elements (counting one three-way comparison per…
- Consider the following C fragment. int c=0; for(int i=0;i<20;i++) for(int j=i+1;j<20;j++) for(int k=j+1;k<20;k++) c++; What is c at the end?