Bit Array

Question 1
Marks : +2 | -2
Pass Ratio : 100%
Which of the following bitwise operator will you use to invert all the bits in a bit array?
OR
NOT
XOR
NAND
Explanation:
NOT operation is used to invert all the bits stored in a bit array.
Question 2
Marks : +2 | -2
Pass Ratio : 100%
Which of the following bitwise operations will you use to set a particular bit to 0?
OR
AND
XOR
NAND
Explanation:
1 AND 0 = 0, 0 AND 0 = 0, any bit AND with 0 gives 0.
Question 3
Marks : +2 | -2
Pass Ratio : 100%
Which of the following is not a disadvantage of bit array?
Without compression, they might become sparse
Accessing individual bits is expensive
Compressing bit array to byte/word array, the machine also has to support byte/word addressing
Storing and Manipulating in the register set for long periods of time
Explanation:
Bit arrays allow small arrays of bits to be stored and manipulated in the register set for long periods of time with no memory accesses because of their ability to exploit bit-level parallelism, limit memory access, and maximally use the data cache, they often outperform many other data structures on practical data sets. This is an advantage of bit array. The rest are all disadvantages of bit array.
Question 4
Marks : +2 | -2
Pass Ratio : 100%
Which of the following bitwise operations will you use to toggle a particular bit?
OR
AND
XOR
NOT
Explanation:
1 XOR 1 = 0, 0 XOR 1 = 1, note that NOT inverts all the bits, while XOR toggles only a specified bit.
Question 5
Marks : +2 | -2
Pass Ratio : 100%
Which class in Java can be used to represent bit array?
BitSet
BitVector
BitArray
BitStream
Explanation:
The BitSet class creates a special type of array that can hold bit values.
Question 6
Marks : +2 | -2
Pass Ratio : 100%
Run-Length encoding is used to compress data in bit arrays.
True
False
Explanation:
A bit array stores the combinations of bit 0 and bit 1. Each bit in the bit array is independent. Run Length encoding is a data compression technique in which data are stored as single value and number of times that value repeated in the data. This compression reduces the space complexity in arrays. Bit arrays without compression require more space. Thus, we will use Run-Length encoding in most of the cases to compress data in bit arrays.
Question 7
Marks : +2 | -2
Pass Ratio : 100%
Which of the following is not an advantage of bit array?
Exploit bit level parallelism
Maximal use of data cache
Can be stored and manipulated in the register set for long periods of time
Accessing Individual Elements is easy
Explanation:
Individual Elements are difficult to access and can’t be accessed in some programming languages. If random access is more common than sequential access, they have to be compressed to byte/word array. Exploit Bit parallelism, Maximal use of data cache and storage and manipulation for longer time in register set are all advantages of bit array.
Question 8
Marks : +2 | -2
Pass Ratio : 100%
Which of the following is/are not applications of bit arrays?
Used by the Linux kernel
For the allocation of memory pages
Bloom filter
Implementation of Vectors and Matrices
Explanation:
Normal Arrays are used to implement vectors and matrices. Bit arrays have no prominent role. Remaining all are applications of Bit Arrays.
Question 9
Marks : +2 | -2
Pass Ratio : 100%
What is a bit array?
Data structure for representing arrays of records
Data structure that compactly stores bits
An array in which most of the elements have the same value
Array in which elements are not present in continuous locations
Explanation:
It compactly stores bits and exploits bit-level parallelism.
Question 10
Marks : +2 | -2
Pass Ratio : 100%
Which of the following bitwise operations will you use to set a particular bit to 1?
OR
AND
XOR
NOR
Explanation:
1 OR 1 = 1, 0 OR 1 = 1, any bit OR’ed with 1 gives 1.