C/C++ Bit Array or Bit Vector
Posted
by
MovieYoda
on Stack Overflow
See other posts from Stack Overflow
or by MovieYoda
Published on 2011-01-05T12:48:42Z
Indexed on
2011/01/05
12:54 UTC
Read the original article
Hit count: 159
Hi, I am learning C/C++ programming & have encountered the usage of 'Bit arrays' or 'Bit Vectors'. Am not able to understand their purpose? here are my doubts -
- Are they used as boolean flags?
- Can one use
int
arrays instead? (more memory of course, but..) - What's this concept of Bit-Masking?
- If bit-masking is simple bit operations to get an appropriate flag, how do one program for them? is it not difficult to do this operation in head to see what the flag would be, as apposed to decimal numbers?
I am looking for applications, so that I can understand better. for Eg -
Q. You are given a file containing integers in the range (1 to 1 million). There are some duplicates and hence some numbers are missing. Find the fastest way of finding missing numbers?
For the above question, I have read solutions telling me to use bit arrays. How would one store each integer in a bit?
© Stack Overflow or respective owner