
searching and sorting
Authored by Khushi Kapoor
Other
University
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
17 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following is correct recurrence for worst case of Binary Search?
T(n) = 2T(n / 2) + O(1) and T(1) = T(0) = O(1)
T(n) = T(n - 1) + O(1) and T(1) = T(0) = O(1)
T(n) = T(n / 2) + O(1) and T(1) = T(0) = O(1)
T(n) = T(n - 2) + O(1) and T(1) = T(0) = O(1)
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Given a sorted array of integers, what can be the minimum worst-case time complexity to find ceiling of a number x in given array? The ceiling of an element x is the smallest element present in array which is greater than or equal to x. Ceiling is not present if x is greater than the maximum element present in array. For example, if the given array is { 12, 67 ,90,100,300,399} and x = 95 then the output should be 100.
O (loglogn)
O(n)
O(log(n))
O( log(n) * log(n))
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
The increasing order of performance of the searching algorithms are:
linear search < jump search < binary search
linear search > jump search < binary search
linear search < jump search > binary search
linear search > jump search > binary search
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
The recurrence relation that arises in relation with the complexity of binary search is:
T(n) = 2T(n / 2) + k
T(n) = T(n / 2) + k
T(n) = T(n / 2)+ log(n)
T(n) = T(n / 2) + n
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following program that attempts to locate an element x in a sorted array a[] using binary search. Assume N>1. The program is erroneous. Under what conditions does the program fail?
x is the last element of the array a
x is greater than all elements of the array
Both of the Above
x is less than the last element of the array a[]
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Question:
Given an array A of size N, what does the prefix sum array P represent?
Prefix sum is a technique used to compute the sum of all elements in an array from the beginning to a given index. The prefix sum array P is an array such that P[i] represents the sum of all elements in A from index 0 to i. This technique is useful in solving problems that involve range sum queries, where the goal is to find the sum of all elements in an array within a given range.
The sum of all elements in A from index 0 to i, for each i from 0 to N-1
The maximum element in A from index 0 to i, for each i from 0 to N-1
The minimum element in A from index 0 to i, for each i from 0 to N-1
The product of all elements in A from index 0 to i, for each i from 0 to N-1
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Given an array A of size N, what does the prefix sum array P represent, where P[i] is computed as the sum of all elements in A from index 0 to i, modulo a prime number M?
The number of pairs of indices (j, k) such that j < k <= i and A[j] = A[k]
The sum of all elements in A from index 0 to i, modulo M, plus the number of prime factors of i+1
The product of all elements in A from index 0 to i, modulo M, raised to the power of the number of distinct elements in A[0..i]
The sum of all elements in A from index 0 to i, modulo M, minus the sum of all elements in A from index i+1 to N-1, modulo M
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?