Count frequency of a number in a sorted array

Given a sorted array of numbers and a number x, count the number of occurrences of x in the array. Input: int arr[] = {1, […]

Find popular element in an array

Given a sorted array of integers, find a “popular” element i.e. one which occurs more than n/4 times. If no such element exist (which occurs more […]

Divide & Conquer Approach to find a^n

If you want to compute a^n ( a raised to the power n), then the algorithm is simple: long power(int a, int n) { long […]