/* */ Click to Join Live Class with Shankar sir Call 9798158723

Data Structure MCQ - Bit Array


Q1.Which of the following bitwise operator will you use to invert all the bits in a bit array
  1. NOT
  2. NAND
  3. OR
  4. AND

Answer:- (A).
Explanations :
Q2.What are some of the applications of bit arrays?
  1. Used by the Linux kernel
  2. Bloom filter
  3. For the allocation of memory pages
  4. All of these

Answer:- (D).
Explanations :Used in priority queues data structure in the Linux kernel, for allocation of memory pages, a bitmap is used.
Q3.Which class in Java can be used to represent bit array?
  1. BitSet
  2. BitStream
  3. BitVector
  4. BitArray

Answer:- (A).
Explanations :The BitSet class creates a special type of array that can hold bit values.
Q4.Which of the following bitwise operations will you use to toggle a particular bit?
  1. OR
  2. AND
  3. XOR
  4. NOT

Answer:- (C).
Explanations :1 XOR 1 = 0, 0 XOR 1 = 1, note that NOT inverts all the bits, while XOR toggles only a specified bit.
Q5.Which of the following is not an advantage of bit array?
  1. Exploit bit level parallelism
  2. Maximal use of data cache
  3. Can be stored and manipulated in the register set for long periods of time
  4. Accessing Individual Elements is easy

Answer:- (D).
Explanations :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.
Q6.Which of the following is not a disadvantage of bit array?
  1. Without compression, they might become sparse
  2. Accessing individual bits is expensive
  3. Compressing bit array to byte/word array, the machine also has to support byte/word addressing
  4. Storing and Manipulating in the register set for long periods of time

Answer:- (D).
Explanations :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.
Q7.Which class in Java can be used to represent bit array?
  1. BitSet
  2. BitVector
  3. BitArray
  4. BitStream

Answer:- (A).
Explanations :The BitSet class creates a special type of array that can hold bit values.
Q8.What does Hamming weight/population count mean in Bit arrays?
  1. Finding the number of 1 bit in a bit array
  2. Finding the number of 0 bit in a bit array
  3. Finding the sum of bits in a bit array
  4. Finding the average number of 1’s and 0’s in bit arrays

Answer:- (A).
Explanations :Hamming/ population count involves finding the number of 1’s in the bit array. Population count is used in data compression.
Q9.Which of the following is/are not applications of bit arrays?
  1. Used by the Linux kernelRead
  2. For the allocation of memory pages
  3. Bloom filter
  4. Implementation of Vectors and Matrices

Answer:- (D).
Explanations :Normal Arrays are used to implement vectors and matrices. Bit arrays have no prominent role. Remaining all are applications of Bit Arrays.
Q10.What is a sorted array?
  1. Arrays sorted in numerical order
  2. Arrays sorted in alphabetical order
  3. Elements of the array are placed at equally spaced addresses in the memory
  4. All of the mentioned

Answer:- (D).
Explanations :The array can be sorted in any way, numerical, alphabetical or any other way but the elements are placed at equally spaced addresses.