This question already has answers here:
C/C++ Bit Array or Bit Vector
(5 answers)
Closed 9 years ago.
I looked online for a good while now, and can't seem to find a good example of what a bit vector actually is.
I have an assignment to do for college which is to add, remove, union of 2 vectors and the intersection too. But I am struggling to comprehend what an actual bit vector is. I am using C to write this.
Could someone please help me on this, it would be a massive help.
Bit vector is a structure which purpose is an accessability of individual bits. Implementation-wise it can be an integer array with some function provided for addressing and manipulation of individual bits of the array. To the final user the array has to look as a "string" of bits, and the functions have to be able to access arbitrary nth bit of the "string".
There is a bitset class in the standard library of C++ which represent this concept, but I am not aware of some option in C language.
Related
This question already has answers here:
Are there any solid large integer implementations in C? [closed]
(7 answers)
Closed 8 years ago.
Recently in programming contest in Here, the problem is pretty straight forward but catch is with worst case scenario which we have to handle data of size 10^10000 .
I tried the program in python which is straight forward as i don't have to specify the datatype(It is taken care by the compiler ) but when i tried with C I couldn't find the correct datatype .
(I tried uintmax_t which didn't work out too).
So how to approach very huge type of data's in C ?
There is no built-in datatype in C that can store that big values. You will either have to write your own implementation or use a library. As this is a competition, though the second is not an option. Every now and then similar problems appear and usually the best approach is to use another language e.g. java(as it is usually available on competitions).
This question already has answers here:
what is meant by normalization in huge pointers
(3 answers)
Closed 9 years ago.
Actually i was studying about huge and far pointers.
I come to know huge pointers are by default in normalized form.
I want to know how can we normalize any pointer?
The huge pointer and far pointer are old concept which live in 16-bit
DOS time. You can search something about DOS programming for more
detail about them.
In 8086 programming (MS DOS), a far pointer is normalized if its offset part is between 0 and 15 (0xF).
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
How to convert struct to char array in C
Portable way of writing a C struct to a file (Serialisation for C)
I am looking for converting a structure to byte array in C and i was confused in doing that.Please show me a right way in achieving that. Thanks in advance.
A structure is a byte array. it starts at &mystruct and has the length of sizeof(mystruct_type) bytes.
If the binaries are to long or do contain gaps, check the #pragma pack settings.
hth
Maro
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What do people find difficult about C pointers?
New to c programming (Actually new to programming in general). Well, I just can't get familiar with c pointers. maybe, I can use them in some situations, but really am stuck to understand it. Anyone been in such a situation? Any suggestions?
I would start at the Introduction to pointers. The link is to a very simple, concise, and easy to follow tutorial/e-learning site. The next chapter goes more in depth. I think you'll find the information helpful in getting a better understanding of how pointers work.
That site discusses things that can confuse people easily. Such as the following syntax differences:
1 int *pnPtr; // a pointer to an integer value
2 double *pdPtr; // a pointer to a double value
3
4 int* pnPtr2; // also valid syntax
5 int * pnPtr3; // also valid syntax
Take a look at What do people find difficult about C pointers?. people discussed what fundamental issues they ran into when trying to learn c pointers.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Converting a Uniform Distribution to a Normal Distribution
Hello.
I'd like to know of any algorithm implemented in C which can take a random value between 0 and 1, the mean and standard deviation and then return a normally distributed result.
I have too little brainpower to figure this out for myself right now.
I can't find anything useful on the internet.
Thank you.
Box-Muller is the transform you need.
There's already been the suggestion for Box Muller, but a computationally simpler approach is simply to take advantage of the central-limit theorem; add enough independent random variables together, and the result will approximate a normal distribution.