Data Structured Flashcards
What is a data structure?
A data structure is a specific way of organising data within memory so it can be processed efficiently. There will be a relationship between the data items that will vary according to the type of data structure being used.
Static data structure.
A static data structure is designed to store a known number of data items. The values of the data can be changed but the memory size is fixed. An array is an example of a static data structure; we can change the values of the elements in the array but we cannot alter the memory size allocated to the array. Memory is allocated at compile-time.
As static data structures store a fixed number of data items, they are easier to program. There is no need to check on the size of the data structure or the number of items stored.
Dynamic data structure
Dynamic data structures are designed to allow the data structure to grow or shrink at runtime. It is possible to add new elements or remove existing elements without having to consider memory space. Memory is allocated at runtime.
Dynamic data structures make the most efficient use of memory but are more difficult to program, as you have to check the size of the data structure and the location of the data items each time you use the data.
List
A list is a data structure that has the data items stored in the order they were originally added to memory. If the list is made up of a set number of data items, it can be a static data structure. If the list can vary in the number of data items, then it will be a dynamic data structure.
An array
An array is a data structure that can hold a fixed number of data items, which must be of the same data type, i.e. real, integer, string etc. The data items in an array are known as elements. An array is an example of a static list.
The elements in an array are identified by a number that indicates their position in the array. This number is known as the index. The first element in an array usually has an index of 0