Data structures and abstract data types Flashcards
Define primitive data type and give an example
They can only contain one data value. e.g. Integer, Boolean, Real etc
Define composite/compound data type and give an example
They’re built by combining primitive data types e.g. Records, Class
Define data structures
A collection of data that is organised to allow efficient processing. This means a wide range of sorting algorithms can be used
Define abstract data types
A conceptual model that describes how data is organised and which operations can be carried out from the perspective of an end user with no background knowledge
How do static data structures deal with memory?
They reserve enough memory for a set amount of data established in advance. The structure can not be resized
How are static data structures efficient and inefficient?
They’re very memory efficient as they can access elements directly by index.
They’re inefficient if the wrong amount of memory is allocated leading to wastage or errors
How do dynamic data structures deal with memory?
The memory capacity is not fixed and the number of elements it can hold is only limited by the memory allocation for the whole program
Name an advantage and disadvantage of dynamic data structures
Advantage is that the memory size is not pre set
A disadvantage is that elements can not be accessed directly- only by memory location which is sequential
What is a memory heap?
The amount of memory allocated to a program at run time that data structures can access
Definition of an array
A data structure that holds a number of elements of the same data type
How are arrays declared & processed?
Declared under a single identifier and processed efficiently using iteration techniques
How do arrays use indexes?
Each position is identified by an index, usually using zero-based indexing. Data is stored contiguously( next to each other) in main memory so each position is directly acessible
Are the values in an array mutable?
Yes, they can be changed while the program is running
What are the three steps to declaring a one dimensional array?
Create an identifier
Specify the data type of the elements
Specify the number of positions in the array
What’s another name for a 2D array?
A Matrix