Bitwise Algorithms - Basic Practice Problems Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report Bitwise algorithms are a category of algorithms that operate on individual bits within a data unit, rather than the entire data unit itself. They leverage bitwise operators, which are special operators designed to perform operations on bits. Common bitwise operators include AND (&), OR (|), XOR (^), and NOT (~). Before diving into the world of bitwise algorithms, a basic understanding of binary representation is crucial. Computers store data in binary form, where each unit (bit) can be either 0 or 1. Numbers we typically use (decimal system) are converted to binary for computer processing. Basic Practice Problems on Bitwise Algorithm:Find the element that appears onceDetect if two integers have opposite signsAdd 1 to a given numberMultiply a given Integer with 3.5Turn off the rightmost set bitFind whether a given number is a power of 4 or notCompute modulus division by a power-of-2-numberRotate bits of a numberFind the Number Occurring Odd Number of TimesCheck for Integer OverflowCount set bits in an integerCount number of bits to be flipped to convert A to BEfficient way to multiply with 7Program to find whether a no is power of twoPosition of rightmost set bitBinary representation of a given numberFind position of the only set bitHow to swap two numbers without using a temporary variable?Swap two nibbles in a byteHow to turn off a particular bit in a number?Russian Peasant (Multiply two numbers using bitwise operators)Add two bit stringsWrite your own strcmp that ignores casesCheck if two numbers are equal without using arithmetic and comparison operatorsFind XOR of two number without using XOR operatorXOR counts of 0s and 1s in binary representationCalculate XOR from 1 to nEqual Sum and XORSwap three variables without using temporary variableCheck if a number has bits in alternate patternXOR of two numbers after making length of their binary representations equalCount minimum bits to flip such that XOR of A and B equal to CEfficient method for 2’s complement of a binary stringToggle case of a string using Bitwise operatorsToggling k-th bit of a numberConvert decimal fraction to binary numberToggle all the bits of a number except k-th bitSet the rightmost unset bitConvert a binary number to octalCheck in binary array the number represented by a subarray is odd or evenToggle the last m bits1 to n bit numbers with no consecutive 1s in binary representationToggle bits in the given rangeUnset bits in the given rangeFind the largest number with n set and m unset bitsFind the smallest number with n set and m unset bitsSum of numbers with exactly 2 bits setCheck if binary representation of a given number and its complement are anagramCheck a number is odd or even without modulus operatorBitwise recursive addition of two integersPrint bitwise AND set of a number NFast average of two numbers without divisionMaximum XOR-value of at-most k-elements from 1 to nSwap every two bits in bytesCheck if a number is divisible by 8 using bitwise operatorsNumber of Reflexive Relations on a SetFor every set bit of a number toggle bits of otherToggle bits of a number expect first and last bitsCheck if given four integers (or sides) make rectangleToggle all even bits of a numberToggle first and last bits of a numberSet the Left most unset bitMaximum XOR using K numbers from 1 to nPython | Count set bits in a rangePython map function | Count total set bits in all numbers from 1 to nCheck whether the bit at given position is set or unsetMultiplication with a power of 2Check if n is divisible by power of 2 without using arithmetic operatorsToggle all odd bits of a numberCount set bits using Python List comprehensionCheck if a number is positive, negative or zero using bit operatorsModify a bit at a given positionCHAR_BIT in CFind One’s Complement of an IntegerAdd two numbers without using arithmetic operatorsMultiply a number with 10 without using multiplication operatorCheck if one of the numbers is one’s complement of the otherCheck if a number has bits in alternate pattern | Set-2 O(1) ApproachSet all the bits in given range of a numberCalculate 7n/8 without using division and multiplication operatorsCount total bits in a numberFind most significant set bit of a numberFind smallest number n such that n XOR n+1 equals to given kCheck if a number has two adjacent set bitsWrite an Efficient Method to Check if a Number is Multiple of 3Extract ‘k’ bits from a given position in a numberPrint ‘K’th least significant bit of a numberCheck if two numbers are equal without using comparison operatorsEfficiently check whether n is a multiple of 4 or notCheck whether K-th bit is set or notCheck if a number is multiple of 9 using bitwise operatorsCompare two integers without using any Comparison operatorMultiplying a variable with a constant without using multiplication operatorCheck whether a given number is even or oddPowers of 2 to required sumSet all even bits of a numberSet all odd bits of a numberPrint numbers having first and last bits as the only set bitsCheck if binary representations of two numbers are anagramMultiples of 4 (An Interesting Method)Given a set, find XOR of the XOR’s of all subsets.Write a function that returns 2 for input 1 and returns 1 for 2Subtract two numbers without using arithmetic operatorsQuick Links : 'Practice Problems' on Bit Magic'Quiz' on Bit Magic'Videos' on Bit Magic Create Quiz Comment H harendrakumar123 Follow 1 Improve H harendrakumar123 Follow 1 Improve Article Tags : Bit Magic DSA Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 3 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 15 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 1 min read Problem of The Day - Develop the Habit of Coding 5 min read Like