Data structures
Categories: data structures
Most computer languages support various data types.
Elementary data types, such as integers, floats, booleans and chars can represent a single value (such as a number or a letter).
Composite data types such as arrays and lists can store more than one value, for example this list contains three numbers:
[10, 20, 30]
Composite data types can be either static or dynamic. Static structures have a fixed size that is determined when the structure is created (arrays are static). Dynamic structures can grow to accommodate more data after they have been created (lists are usually dynamic).
Storing composite data types in memory can be quite complicated. For example, if you wanted to store a list, you would need to store:
- The elements of the list (each in its own memory location).
- The length of the list (the number of elements).
- Probably a memory pointer to tell you where to find the elements.
The collection of all these values is called a data structure.
Data structures typically have built in code to manage them. For example with a list you have to worry about what happens if you add extra elements to the list - will there be enough memory to store all the data, and what do you do if you need more? In fact there are several different ways to create a list, such as array lists or linked lists.
Fortunately, you don't usually need to create your own data structures. Most languages provide a set of abstract data types that you can use without needing to worry about how they work.
See also
Sign up to the Creative Coding Newletter
Join my newsletter to receive occasional emails when new content is added, using the form below:
Popular tags
555 timer abstract data type abstraction addition algorithm and gate array ascii ascii85 base32 base64 battery binary binary encoding binary search bit block cipher block padding byte canvas colour coming soon computer music condition cryptographic attacks cryptography decomposition decryption deduplication dictionary attack encryption file server flash memory hard drive hashing hexadecimal hmac html image insertion sort ip address key derivation lamp linear search list mac mac address mesh network message authentication code music nand gate network storage none nor gate not gate op-amp or gate pixel private key python quantisation queue raid ram relational operator resources rgb rom search sort sound synthesis ssd star network supercollider svg switch symmetric encryption truth table turtle graphics yenc