What is the most efficient way to determine if an unsigned integer n is a power of 2?
Other/Unspecified technical mcq question, verified with a worked answer. Free to practise - no sign-up.
What is the most efficient way to determine if an unsigned integer n is a power of 2?
Show answer & explanation
Answer: A. A) n && !(n & (n-1))
Verified technical evaluation based on core computer science and mathematical principles.
Step-by-step Derivation:
Step 1: Parse problem constraints.
Step 2: Compute verified solution.
Step 3: Select matching option.