Data Structures

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

Types of Data Structure

Data structures are either:

  • Strong
  • Static
  • Dynamic

Strong Data Structures

Strong types are the standard types, ie standard variable types typically available in a programming language. Examples:

  • Integer.
  • Character.
  • String.
  • Boolean.
  • Double (Decimal, Float).

These strong types provide the basis for all other types, for example a Static array is an array of a strong type.

Strong types are allocated a fixed amount of memory when defined.

Static Data Structure

With a static data structure, the size of the structure is fixed. Static data structures are very good for storing a well-defined number of data items. For example a programmer might be coding an 'Undo' function where the last 10 user actions are kept in case they want to undo their actions. In this case the maximum allowed is 10 steps and so he decides to form a 10 item data structure. This is done in the coding, and must be changed in the code to change the size of the structure.

Dynamic Data Structure

There are many situations where the number of items to be stored is not known before hand. Memory is allocated to the data structure dynamically i.e. as the program executes. In this case the programmer will consider using a dynamic data structure. This means the data structure is allowed to grow and shrink as the demand for storage arises. The programmer should also set a maximum size to help avoid memory issues. For example a programmer coding a print spooler will have to maintain a data structure to store print jobs, but he cannot know before hand how many jobs there will be.