0

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!

  • 4
    First result from [googling Pascal Set](http://www.tutorialspoint.com/pascal/pascal_sets.htm)... Also I don't see anything odd about using Pascal, it is still fairly popular (being in the top 20 in the TIOBE index) and a good programming language – UnholySheep Oct 23 '16 at 11:50
  • 1
    Also http://docwiki.embarcadero.com/RADStudio/Berlin/en/Structured_Types_(Delphi) – Dalija Prasnikar Oct 23 '16 at 11:54
  • basically it'll be implemented as a [bit array](http://wiki.freepascal.org/Bit_manipulation#Set) or [red-black tree](http://en.cppreference.com/w/cpp/container/set) – phuclv Oct 23 '16 at 11:59
  • Thanks, on embarcadero it was explained well –  Oct 23 '16 at 12:07

1 Answers1

0

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.

Paul Ogilvie
  • 25,048
  • 4
  • 23
  • 41
  • 1
    A Pascal `set`, however, is a bitset, i.e. a number of bytes of which each bit can be addressed by an integer or an enumerated type. So the set `[1,5,7]` contains the elements with value 1, 5 and 7. This means that the bits 1, 5, and 7 of the bytes that make up the set are set and the other bits are clear. – Rudy Velthuis Oct 23 '16 at 18:35
  • 1
    And there is only one implementation of Pascal sets. Note that in Pascal, sets are part of the language. – Rudy Velthuis Oct 23 '16 at 18:36
  • @Rudy Velthuis, thanks! – Paul Ogilvie Oct 23 '16 at 20:25