Category Archives: Searching

Given two sorted arrays, a[] and b[], the task is to find the median of these sorted arrays, in O(log n + log m) time… Read More
Given a book of words. Assume you have enough main memory to accommodate all words. design a data structure to find top K maximum occurring… Read More
Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s. Example: Input matrix 0 1 1… Read More
Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X. For example,… Read More
Given an unsorted array and a number n, find if there exists a pair of elements in the array whose difference is n. Examples: Input:… Read More
Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array. Examples : Input: arr[] = {8,… Read More
Given an array of n distinct integers sorted in ascending order, write a function that returns a Fixed Point in the array, if there is… Read More
Given an unsorted array of size n. Array elements are in the range from 1 to n. One number from set {1, 2, …n} is… Read More
Given two arrays: arr1[0..m-1] and arr2[0..n-1]. Find whether arr2[] is a subset of arr1[] or not. Both the arrays are not in sorted order. It… Read More
Interpolation search works better than Binary Search for a sorted and uniformly distributed array. On average the interpolation search makes about log(log(n)) comparisons (if the… Read More
Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[]. Expected time complexity is O(Logn)… Read More
Given a sorted array and a value x, the ceiling of x is the smallest element in array greater than or equal to x, and… Read More
  Question: Write an efficient program for printing k largest elements in an array. Elements in array can be in any order.For example, if given… Read More
Write a C function to return minimum and maximum in an array. Your program should make the minimum number of comparisons.  Recommended: Please solve it… Read More