Exponential search
Given a sorted array of n integers and a target value, determine if the target exists in the array or not in logarithmic time. If the target exists in the array, print an index of it.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a sorted array of n integers and a target value, determine if the target exists in the array or not in logarithmic time. If the target exists in the array, print an index of it.
Given a sorted integer array and a target, determine if the target exists in the array or not using an interpolation search. If the target exists in the array, print an index of it.
Given a sorted array of n integers and a target value, determine if the target exists in the array or not in logarithmic time using the binary search algorithm. If target exists in the array, print the index of it.
Given a sorted array of distinct positive integers, print all triplets that forms a geometric progression with an integral common ratio.
Given an array of positive and negative integers, segregate them in linear time and constant space. The output should print all negative numbers followed by all positive numbers.
Given an array, find the total number of inversions of it. If (i < j) and (A[i] > A[j]), then pair (i, j) is called an inversion of an array A. We need to count all such pairs in the array.
Given two arrays, reorder elements of the first array by the order of elements defined by the second array. The elements that are not present in the second array but present in the first array should be appended at the end sorted.
Given an array, sort its element by their frequency and index. i.e., if two elements have different frequencies, then the one which has more frequency should come first; otherwise, the one which has less index should come first.
The external merge sort algorithm is used to efficiently sort massive amounts of data when the data being sorted cannot be fit into the main memory (usually RAM) and resides in the slower external memory (usually a HDD).
A Hybrid Algorithm is an algorithm that combines two or more other algorithms that solve the same problem. In this article, a hybrid of the Quicksort with Insertion Sort is discussed to achieve better performance.
Write an iterative version of the recursive Quicksort algorithm.
Quicksort is an efficient in-place sorting algorithm, which usually performs about two to three times faster than merge sort and heapsort when implemented well. Quicksort is a comparison sort, meaning that it can sort items of any type for which a less-than relation is defined.