Searching Sheet
Searching Sheet
Example 1:
Input:
N = 5, S = 12
A [] = {1,2,3,7,5}
Output: 2 4
Explanation: The sum of elements
from 2nd position to 4th position
is 12.
Input:
N = 5
A [] = {1,2,3,5}
Output: 4
Example 2:
Input:
N = 10
A [] = {6,1,2,8,3,4,7,10,5}
Output: 9
(3) Kth smallest element
Given an array arr [] and an integer K where K is smaller than size of array, the task
is to find the Kth smallest element in the given array. It is given that all array
elements are distinct.
Example 1:
Input:
N = 6
arr [] = 7 10 4 3 20 15
K = 3
Output: 7
Explanation:
3rd smallest element in the given
array is 7.
Example 2:
Input:
N = 5
arr [] = 7 10 4 20 15
K = 4
Output: 15
Explanation:
4th smallest element in the given
array is 15.
(4) 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? Ceiling of an element x is the
smallest element presents in array which is greater than or equal to x. Ceiling is
not present if x is greater than the maximum element presents in array. For example,
if the given array is {12, 67, 90, 100, 300, 399} and x = 95, then output should be 100.
A. O(LogLogn)
B. O(n)
C. O(Logn)
D. O(Logn*Logn)