Like QuickSort, Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then… Read More »
We are given an array of n points in the plane, and the problem is to find out the closest pair of points in the… Read More »
Like Greedy and Dynamic Programming, Divide and Conquer is an algorithmic paradigm. A typical Divide and Conquer algorithm solves a problem using following three steps.
This is an extension of median of two sorted arrays of equal size problem. Here we handle arrays of unequal size also.
Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array.
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 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)
Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array?
Method 1 (Using Nested Loops) We can calculate power by using repeated addition.
Write a C function to return minimum and maximum in an array. You program should make minimum number of comparisons.
Question: Write a C function to find if a given integer x appears more than n/2 times in a sorted array of n integers.
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count… Read More »
There are 2 sorted arrays A and B of size n each. Write an algorithm to find the median of the array obtained after merging… Read More »
Given two integers x and n, write a function to compute xn. We may assume that x and n are small and overflow doesn’t happen.… Read More »