bitwise algorithm Bitwise Operators + tricks In this article at OpenGenus, we have covered the basics of Bit manipulations, conversions between number systems and clever tricks with bitwise operators.
bitwise algorithm Find the rightmost set bit in a number (+ toggle it) Finding the rightmost set bit in a number is a common problem in computer science and is used in many applications, from competitive programming to low-level programming and data compression. In this article, we will explore various techniques to find the rightmost set bit in a number.
Algorithms Nearest smaller and greater numbers with same number of set bits In this article, we shall explore the various ways we can find the Nearest smaller and greater numbers with same number of set bits for given number.
Algorithms Find smallest of 3 integers without comparison In this guide, we will go through how to get the smallest of three numbers without using Comparison operation. We have presented 3 different techniques using decrement, division and shift operation.
Algorithms Absolute value of Integer using Bitwise Operations In this article, we have explained two approaches to find the Absolute value of Integer using Bitwise Operations namely Right shift, OR and XOR operations.
Algorithms Swap two bits in a number In this problem, we have to swap bits in a given number or an integer. This can be solved in constant time O(1) using XOR operation.
Algorithms Rotate Image: matrix of size NxN by 90 degrees (clockwise) In this article, we have explored an efficient way to Rotate Image: matrix of size NxN by 90 degrees (clockwise) inplace by using a property of XOR operation.
Algorithms Applications of XOR operation We will begin with a brief introduction of what the XOR operation is, followed by its syntax in C++ and its applications such as memory-optimized doubly linked lists, swapping, XOR ciphers, Comparing two values, Gray codes and Partiy check.
Algorithms Swap 2 variables [6+ techniques] We have explored about Swapping of 2 variables. We have presented different methods to do so including swapping using third variable, using arithmetic operations, XOR, macro and much more along with their pros and cons.
Algorithms Multiplication using bitwise operations We have explained how to compute Multiplication using Bitwise Operations. We can solve this using left shift, right shift and negation bitwise operations.
Algorithms Brian Kernighan's Algorithm In this article, we will learn what are set bits and how to count them. And we will also learn about Brian Kernighan's algorithm a famous algorithm to find the number of set bits in a number.
Algorithms Division using Bitwise Operations We will see how to divide a number using the bitwise operator >> rather than using the regular division operator / or the multiplication operator * or the modulo operator %.
Algorithms Comparison using bitwise operations We have explored the idea of making comparisons (equal, larger, smaller) through bitwise operations along with the basic idea of bitwise operations and their examples.
Algorithms Maximum XOR of two numbers in an array using Trie Given a list of numbers we need to identify a pair of numbers in the list such that the XOR of those numbers is the maximum possible over all the pairs.
Algorithms Travelling Salesman Problem (Bitmasking and Dynamic Programming) In this article, we will start our discussion by understanding the problem statement of The Travelling Salesman Problem perfectly and then go through the basic understanding of bit masking and dynamic programming.
Algorithms Minimum Bitwise OR operations to make any two array elements equal Given an array of integers and an integer K, we can perform the Bitwise OR operation between K and elements of the array any number of times. We have to count minimum number of such operations that are required to make any two elements of the array equal.
Algorithms Counting number of set bits (1) in a number (Brian Kernighan Algorithm) With this article at OpenGenus, you must have the complete idea of Counting the number of set bits (1) in a number using naive approach and Brian Kernighan Algorithm.
Algorithms String Matching using Bitset In this article, we have explored how to solve string matching problem (find all occurences of string S1 in another string S2) using Bitset. It is a modification of the naive approach which takes O(L x P x logL) time complexity which improves to O(L x P / K) using bitset.
bitwise operation Algorithm to detect whether two numbers have opposite signs using bitwise operators We present a bitwise algorithm to detect whether two numbers have opposite signs. This is important as using comparision based operations is slow and nearly all hardware support optimizations for bitwise operations
bitwise operation Bitwise Algorithm to Find the Number Occurring with Odd Frequency We have explored the bitwise algorithm to find the only number occuring odd number of times in a given set of numbers. We have used the XOR operator to solve this problem in O(N) time complexity in contrast to the native algorithm which takes O(N^2) time complexity. The space complexity is constant.