• Ruby Algorithms
  • Searching
  • Sorting
  • Arrays
  • Bit Algorithms
  • Mathematics
  • About
    • Algorithms
      • Searching
      • Sorting
      • Bit Algorithms
      • Greedy Algorithms
      • Dynamic Programming
      • Mathematical Algorithms
    • Data-structures
      • Linked list
      • Arrays
    • Extras
      • About

    Bit Algorithms

    This is arrays page

    Check if a given number is even or odd

    Given a number,check if it is even or odd using bit operations. Algorithm: let num be x find x&1 ,if result is 0 then even else odd. The Least sign...

    Check if a given number is power of two

    Given a number,check if it is power of 2 or not without using division or modulo operator.

    Count number of set bits in binary notation

    Given a number “n”,count the number of set bits in it. Algorithm(Brian Kernighan’s method): 1. set count=0 2. while n>0 set n:=n&(n-1) incre...

    Unset the least significant bit

    Given a binary number unset the rightmost set bit. Algorithm: The biwise “&” of any number n with n-1 unsets the rightmost set bit e.g. 5=101 ,5-1=4=100 ...

    • Follow:
    • GitHub
    • Feed
    © 2016 Ruby Algorithms. Powered by Jekyll.