Sum of sum of all subsets of a set formed by first N natural numbers

Given N, and ff(N) = f(1) + f(2) + …… + f(N), where f(k) is the sum of all subsets of a set formed by… Read More »

Weird Number

In number theory, a weird number is a natural number that is abundant but not semiperfect. In other words, the sum of the proper divisors… Read More »

Semiperfect Number

In number theory, a semiperfect number or pseudoperfect number is a natural number n that is equal to the sum of all or some of… Read More »

Find all distinct subset (or subsequence) sums of an array | Set-2

Given an array of N positive integers write an efficient function to find the sum of all those integers which can be expressed as the… Read More »

Number of subsets with sum divisible by m

Given an array of integers, find number of subsequence such that the sum of the subsequence is divisible by m. It is given that sum… Read More »

Recursive program to generate power set

Given a set represented as string, write a recursive code to print all subsets of it. The subsets can be printed in any order. Examples:… Read More »

Maximum subset with bitwise OR equal to k

Given an array of non negative integers and an integer k, find the subset of maximum length with bitwise OR equal to k. Examples :… Read More »

Print equal sum sets of array (Partition Problem) | Set 2

Given an array arr[]. Determine whether it is possible to split the array into two sets such that the sum of elements in both the… Read More »

Sum of bitwise OR of all possible subsets of given set

Given an array arr[] of size n, we need to find sum of all the values that comes from ORing all the elements of the… Read More »

Fibonacci sum of a subset with all elements <= k

Given an array of n elements, the task is to find the fibonacci sum of a subset of the array where every element of the… Read More »

Number of subsets with product less than k

You are given an array of n-elements, you have to find the number of subsets whose product of elements is less than or equal to… Read More »

Number of possible Equivalence Relations on a finite set

An equivalence relation is Reflexive, Symmetric and Transitive. Before counting the number of possible equivalence relations on a set |A|=n, let us see an example… Read More »

Minimize the absolute difference of sum of two subsets

Given a number n, divide first n natural numbers (1, 2, …n) into two subsets such that difference between sums of two subsets is minimum.… Read More »

Backtracking to find all subsets

Given a set of positive integers, find all its subsets. Examples: Input : 1 2 3 Output : // this space denotes null element. 1… Read More »

Largest divisible pairs subset

Given an array of n distinct elements, find length of the largest subset such that every pair in the subset is such that the larger… Read More »