David David - 3 years ago 210
C Question

Pascal - how sets work?

I'm going to a high school programming competition tomorrow, and they use Pascal, about which I can't find much information on the internet, or if I do, I can't really understand it (English isn't my native language).

It would be much appreciated if - someone who still remembers, would explain me: what is a set? Or, how would it look like in C programming language? I guess it's something related to arrays, but I'm not sure though.

Thanks for help in advance!

Answer Source

A set is an unordered collection of elements in which each element can occurr only once.

Depending on what the unique identification of an element is, there can be many ways to implement a set, in any language.

For example, the unique identification is a name and it is mapped onto a number from zero to the size of the set in some way, and this number is used as an index into an array where each array element is [a pointer to] the element. Or there is an array of 32 bit ints and each bit tells whether the element exists in the set and the elements themselves are stored by number in an ordered linked list.

So you see, whithout having more information of what is to be stored in the set, there are numerous implementations possible.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download