Bit Magic - Basic Articles
Given an array, write a program to add the minimum number(should be greater than 0) to the array so that the sum of array becomes… Read More
A number N is given. We need to print its ‘K’th Least Significant Bit.Examples :   Input : num = 10, k = 4 Output :… Read More
The following are not allowed to use  Comparison Operators  String function Examples:   Input : num1 = 1233, num2 =1233Output : Same Input : num1 =… Read More
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 an array such that all its terms is either 0 or 1.You need to tell the number represented by a subarray a[l..r] is odd… Read More
Given an array ‘arr1’ of n positive integers. Contents of arr1[] are copied to another array ‘arr2’, but numbers are shuffled and one element is… Read More
For a given number n, if k-th bit is 0, then toggle it to 1 and if it is 1 then, toggle it to 0.Examples… Read More
Given a number N and a bit number K, check if the Kth bit of N is set or not. A bit is called set… Read More
Given an array A[] having n positive elements. The task to create another array B[] such as B[i] is XOR of all elements of array… Read More
Given a sequence of three binary sequences A, B and C of N bits. Count the minimum bits required to flip in A and B… Read More
Given two integers A & B. Task is to check if A and B are same or not without using comparison operators.Examples:  Input : A… Read More
Given an integer n > 0, the task is to find whether this integer has an alternate pattern in its bits representation. For example- 5… Read More
Given a number, the task is to multiply it with 10 without using multiplication operator?Examples:   Input : n = 50 Output: 500 // multiplication of… Read More
Given a number, check whether it is even or odd. Examples :  Input: 2 Output: even Input: 5 Output: odd Recommended Practice Odd Even Problem… Read More
Given a Binary Number as a string, print its 1’s and 2’s complements.  1’s complement of a binary number is another binary number obtained by… Read More
Given two numbers, the task is to check if two numbers are equal without using Arithmetic and Comparison Operators or String functions. Method 1 : The… Read More
  Given two variables, x, and y, swap two variables without using a third variable.  Method 1 (Using Addition and subtraction)  The idea is to… Read More
Given a number N having only one ‘1’ and all other ’0’s in its binary representation, find position of the only set bit. If there… Read More
Given two signed integers, write a function that returns true if the signs of given integers are different, otherwise false. For example, the function should… Read More
Given two numbers A and B. Write a program to count the number of bits needed to be flipped to convert A to B.  Examples: … Read More