Count Set Bits
C Program to count the set bits:
C Program to count the set bits:
Uses the definition of n! to generate the permutations. Idea: Remove each item from the given n items one at a time and append it to remaining (n-1)! permutations. Efficiency: O(n!) and as well we have expensive swaps Strategy used: Decrease and Conquer(decrease by 1)
To check if the number is multiple of 8, the bitwise way is that: first right shift by 3 and then left shift by 3. Multiple of 8 will remain the same as original number after this operation. Examples: 8: 1000 >> 3 : 0001 <<3 : 1000 24: 11000… Continue reading Multiples of 8
To check if all the bits are set for a given number, AND the given number n with n+1. If all the bits are set, then the result will be 0. Examples: n = 4 100 n+1 = 5 101 ———————– AND result 100 n =… Continue reading Check if all Bits Set
Originally posted on PH Bytes:
A disjoint-set data structure, also called a union–find data structure keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. With this setting we define the following operations: Find: Determine which subset a particular element is in. This can be used for determining if two…
To check if alternate bits are set, Carry out the following operations: First XOR the number n and (n >> 1). If alternate bits are set then this will produce all 1’s. Let us call the result as m To check is all the bits are set to 1, AND m with m + 1… Continue reading Checking Alternate Bits Set
Consider the following: and, As we can clearly see, XOR simulates binary addition without the carry over to the next digit.
Originally posted on PH Bytes:
This post covers the three implementation(Iterative, Recursive and Dynamic) version of Fibonacci series. The correctness of the code covers for integer range numbers only. 1. Iterative Version #include int fibo(int n) { int previous = 1; int current = 1; int next = 1; int i; for (i = 3;…
Originally posted on Its PH:
Those numbers sure call for a ‘Happy Dance’. The blogging journey began on 16 July 2014 with the post Is this Life All About? – A New Old. The blog today has 488 posts, 101 pages, 12,501 comments and 3434 followers. Thank you, you kind fellow bloggers and friends. 100000 hits…
Lets talk them out!
the world of wonders with amazing words
My best traveling tips for your unforgettable journey.
There are always gonna be flaws in the plan. Nothing is perfect. Neither the blog, its url or the blogger. Make yourself home in the chaos.
collecting moments that stump
Welcome to your new home on WordPress.com
With sweet and sour experiences, life is full of colors
Every beat of my heart belongs to I AM! 💙
Impartial Everytime Always
The power of the python programming language unleashed.
Food Photography & Recipes
Embracing Complexity
Intelectual Emergence "The whole is greater than the sum of its parts"
... and in between
~~~BELLA GIRLSS FUR EVER~~~