Question: Multiple Choice Questions Q1: Consider searching element 45 using binary search in an array A [ ] = { 23, 34, 45, 67, 78, 54,

Multiple Choice Questions

Q1: Consider searching element 45 using binary search in an array A [ ] = { 23, 34, 45, 67, 78, 54, 87, 91 }. The returned index would be

  1. Index [0]
  2. Index [2]
  3. Index [3]
  4. None of these

Q2: In the context of recursive search

  1. Recursion terminates when the item is found
  2. Same function is called again and again
  3. Slower than iterative search
  4. All options are correct

Q3: Which one of the following is an approach for a systematic trial and error to search an item?

  1. Binary search
  2. Backtracking
  3. Recursion
  4. Iteration

Q4: In terms of time efficiency, the following method is ____.

public int function(int n) { int result = 1; for (int k = 1; k <= n; k++) result = result * k; return result; }

  1. O(1)
  2. O(n)
  3. O(n2)
  4. O(n log n)

Q5: Which one of the following do not match with others?

  1. pop
  2. push
  3. enqueue
  4. peek

Q6: The quicksort is being used to sort an array in the ascending order. Which one of the following is not true ?

  1. All the elements in the left subarray are less than or equal to the pivot
  2. All the elements in the right subarray are larger than the pivot
  3. The pivot is placed between the two subarrays
  4. All the elements in the right subarray are less than or equal to the pivot

Q7: Which of the following syntax is true with respect to generic declaration:

  1. methodModifiers returnType methodName(methodParameters)
  2. methodModifiers < > returnType methodName(methodParameters)
  3. methodModifiers returnType methodName (methodParameters)
  4. methodModifiers returnType methodName(methodParameters)

Q8: Given a function f(n) = n2 + 20n on an input parameter n, which of the following is true

  1. f(n)=O(1)
  2. f(n)=O(n)
  3. f(n)=O(logn)
  4. f(n)=O(n3)

Q9: A normal queue, if implemented using an array of size MAX_SIZE, gets full when-

  1. Rear = MAX_SIZE 1
  2. Front = (rear + 1)mod MAX_SIZE
  3. Front = rear + 1
  4. Rear = front

Q10: Consider the given function. The function grows at a __________ rate

public static int search(int[] x, int target) {

for(int i=0; i < x.length; i++) { if (x[i]==target) return i; }

return -1; // target not found

}

  1. Constant
  2. Logarithm
  3. Linear
  4. Quadratic

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!