Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Contents
1. Given an unsigned int, swap the bits in odd and even positions
Solution
Code
2. Print the binary representation of an unsigned int
Solution
Code
3. Compute whether or not an unsigned number is a power of two
Solution
Code
4. Set the i-th bit
Solution
5. Unset the i-th bit
Solution
6. Toggle the i-th bit
Solution
7. Given an unsigned number with only one bit set, find the position of this bit
Solution
Code
Solution
Code
Solution
Code
8. Count the number of bits set in an unsigned number
Solution
Code
Solution for sparse bitmaps
Code
Solution for dense bitmaps
Code
Solution for 32bit integers
Code
9. Add two numbers without using arithmetic operators
Solution
Code
10. Given an array of integers where all the numbers are appearing twice find the only number which appears once
Solution
Code
11. Given an array of integers where all the numbers are appearing twice find the only two numbers which appears once
Solution
Code
12. Multiply two numbers without using arithmetic operators
Solution
Code
13. Compute the two’s complement for a given integer
Solution
Code
14. Isolate the rightmost bit set to 1
Solution
15. Create a mask for trailing zeros
Solution
16. Compute parity for a 32 bit number
Solution
Code
17. Swap two integers variables with no additional memory
Solution
Code
18. Swap bit i and j in a 64 bit number
Solution
Code
19. Reverse the order of bits in an unsigned integer
Solution
Code
20. Convert an integer to a string and a string to an integer
Solution
Code
21. Convert a number from base b1 to base b2
Solution
Code
22. Given a set S, compute the powerset of S
Solution
Code
23. Add two decimal strings representing two integers
Solution
Code
24. Generate all the bit patterns from 0 to such that successive patterns differ by one bit.
Solution
Code
25. Represent unsigned integers with variable length encoding using the continuation bit
Solution
Code
26. Represent an integer with variable length encoding using gamma encoding
Solution
Code
27. Represent an integer with variable length encoding using delta encoding
Solution
Code
28. Compute the average with no division
Solution
← Prev
Back
Next →
← Prev
Back
Next →