Question bank › Bit Manipulation
Dsa Bit Manipulation Easy

The Binary Braider

In a custom signal processing unit, you are tasked with 'braiding' two 16-bit unsigned integers, A and B, into a single 32-bit unsigned integer. The braiding process works as follows: the 32nd bit (MSB) of the result is the 16th bit of A, the 31st bit of the result is the 16th bit of B, the 30th bit is the 15th bit of A, the 29th bit is the 15th bit of B, and so on, until the 1st bit (LSB) which is the 1st bit of B. Input: Two space-separated integers A and B (0 <= A, B < 65536). Output: A single integer representing the 32-bit braided result. Example: Input: 2 1 Binary A (16-bit): 0000000000000010 Binary B (16-bit): 0000000000000001 Braid: bit 1 of A is 1, bit 0 of B is 1. All other bits 0. Bit 1 of result (from B) = 1. Bit 2 of result (from A) = 0. Bit 3 of result (from A) = 1. Bit 0 of result (from B) = 1. Wait, let's follow the rule: Result[2*i+1] = A[i], Result[2*i] = B[i]. For A=2 (10 binary) and B=1 (01 binary): Result bit 0 = B bit 0 = 1 Result bit 1 = A bit 0 = 0 Result bit 2 = B bit 1 = 0 Result bit 3 = A bit 1 = 1 Output: 9

Key concepts

bit_manipulationinterleaving

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.