Question
URGENT PLEASE Section A: Multiple Choice Questions (10 marks, Tick () the correct answer) Q1: Consider searching element 45 using binary search in an array
URGENT PLEASE
Section A: Multiple Choice Questions (10 marks, Tick () the correct answer)
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
- Index [0]
- Index [2]
- Index [3]
- None of these
Q2: In the context of recursive search
- Recursion terminates when the item is found
- Same function is called again and again
- Slower than iterative search
- All options are correct
Q3: Which one of the following is an approach for a systematic trial and error to search an item?
- Binary search
- Backtracking
- Recursion
- 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; }
- O(1)
- O(n)
- O(n2)
- O(n log n)
Q5: Which one of the following do not match with others?
- pop
- push
- enqueue
- peek
Q6: The quicksort is being used to sort an array in the ascending order. Which one of the following is not true ?
- All the elements in the left subarray are less than or equal to the pivot
- All the elements in the right subarray are larger than the pivot
- The pivot is placed between the two subarrays
- 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:
- methodModifiers returnType methodName(methodParameters)
- methodModifiers < > returnType methodName(methodParameters)
- methodModifiers
returnType methodName (methodParameters) methodModifiers returnType methodName(methodParameters)
Q8: Given a function f(n) = n2 + 20n on an input parameter n, which of the following is true
- f(n)=O(1)
- f(n)=O(n)
- f(n)=O(logn)
- f(n)=O(n3)
Q9: A normal queue, if implemented using an array of size MAX_SIZE, gets full when-
- Rear = MAX_SIZE 1
- Front = (rear + 1)mod MAX_SIZE
- Front = rear + 1
- 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
}
- Constant
- Logarithm
- Linear
- Quadratic
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started