## Swap Adjacent Bits of a Number

Given an integer, swap adjacent bits of it. In other words, swap bits present at even positions with those present in odd positions.

Coding made easy

Given an integer, swap adjacent bits of it. In other words, swap bits present at even positions with those present in odd positions.

Given a set S, generate all distinct subsets of it i.e., find distinct power set of set S. A power set of any set S is the set of all subsets of S, including the empty set and S itself.

Given an array of integers, duplicates appear in it even number of times except two elements which appears odd number of times. Find both odd appearing element without using any extra memory.

Given an integer, swap two bits at given positions in binary representation of it.

Given two integers, add their binary representation.

Given an array of integers, duplicates are present in it in such a way that all duplicates appear even number of times except one which appears odd number of times. Find that odd appearing element in linear time and without using any extra memory.

Given a number, check if it is power of four or not.

Given a number, check if it is power of 8 or not.

Given an integer, reverse its bits using binary operators. The idea is to initialize the result by 0 (all bits 0) and process the given number starting from its least significant bit. If the current bit is 1, then we set the corresponding most significant bit in the result and finally move on …

Huffman Coding (also known as Huffman Encoding) is a algorithm for doing data compression and it forms the basic idea behind file compression. This post talks about fixed length and variable length encoding, uniquely decodable codes, prefix rules and construction of Huffman Tree.

Given an array of integers with all its elements between 1 to n with the exception of two elements which occur twice. Find two duplicate elements without using any extra memory.

Given a positive number N, efficiently generate binary numbers between 1 to N using queue data structure and in linear time.