Interview Questions

Microsoft Interview Question about Bit Manipulation

Microsoft Interview Questions and Answers


(Continued from previous question...)

Microsoft Interview Question about Bit Manipulation

Question:
find the index of the highest bit set of a 32-bit number (without loops obviously)


maybe an answer:


Just traverse from the left hand side of the number and searching for the first element other than zero. or

floor(LOGbase2(n))

or use lookup table. it solves the problem in O(1)

(Continued on next question...)

Other Interview Questions