# Category Archives: Algorithm

## Exact Cover Problem and Algorithm X | Set 1July 12, 2017

If you have ever tried to create a program for solving Sudoku, you might have come across the Exact Cover problem. In this article, we… Read More »

## Master Theorem For Subtract and Conquer Recurrences

Master theorem is used to determine the Big – O upper bound on functions which possess recurrence, i.e which can be broken into sub problems.… Read More »

## Squareroot(n)-th node in a Linked List

Given a Linked List, write a function that accepts the head node of the linked list as a parameter and returns the value of node… Read More »

## Count number of pairs (A <= N, B <= N) such that gcd (A , B) is B

Given a number n. We need find the number of ordered pairs of a and b such gcd(a, b) is b itself Examples: Input :… Read More »

## Find the last digit of given seriesJuly 11, 2017

Given an integer n, find the last digit of this sequence, i.e. Summation of F(n) from i = 0 to 2i ≤ n, where F(n)… Read More »

## Recursive selection sort for singly linked list | Swapping node links

Given a singly linked list containing n nodes. The problem is to sort the list using recursive selection sort technique. The approach should be such… Read More »

## Why is it faster to process sorted array than an unsorted array ?

Here is a C++ code that illustrates that sorting the data miraculously makes the code faster than the unsorted version. Let’s try out a sample… Read More »

## Sort the biotonic doubly linked list

Sort the given biotonic doubly linked list. A biotonic doubly linked list is a doubly linked list which is first increasing and then decreasing. A… Read More »

## LS3/NS3 sphere generation algorithm and its implementation

Given center of the sphere and its radius. your task is to store efficiently all the integer points required to show a sphere on the… Read More »

## Sum of all proper divisors of natural numbers in an array

Given an array of natural numbers count the sum of its proper divisors for every element in array. Input : int arr[] = {8, 13,… Read More »

## Find the largest number with n set and m unset bitsJuly 10, 2017

Given two non-negative numbers n and m. The problem is to find the largest number having n number of set bits and m number of… Read More »

Given a number n, write a program to check whether given number is Adam Number or not. Adam number is a number when reversed, the… Read More »

## Finding power of prime number p in n!

Given a number ‘n’ and a prime number ‘p’. We need to find out the power of ‘p’ in prime factorization of n! Examples: Input… Read More »

## Compute the parity of a number using XOR and table look-upJuly 9, 2017

Parity of a number refers to whether it contains an odd or even number of 1-bits. The number has “odd parity”, if it contains odd… Read More »

## Find length of longest subsequence of one string which is substring of another string

Given two string X and Y. The task is to find the length of longest subsequence of string X which is substring in sequence Y.… Read More »