Data Structures Flashcards
What data type is an integer and why?
Primitive - as it can only contain 1 value
What are some examples of primitive data types?
Integers
What is a compound/composite data type? What is an example?
More than 1 primitive data types combined together for example, a record or a class
Define data structure
Collection of data that is organised to allow efficient processing
Define abstract data type
A conceptual model that describes how data is organised and which operations can be carried out on the data (i.e. delete, insert) from the perspective of an end user who does not know how it is implemented
What do static data structures do with memory? Who controls this?
Reserves memory for a set amount of data - the programmer establishes this in advance
How is an array usually implemented?
As a static data structure that is fixed in size and can only contain elements of the same data type
What can and cannot be changed in a static data structure? What would you need to do if you wanted to change something that cannot be changed?
The contents can be changed however the size of it cannot be changed - if you needed an array of a different size, you would need to create a whole new array and then copy the contents from the original array to the new structure
How are static data structures efficient?
Can access elements directly (by index)
How are static data structures inefficient?
In terms of memory use - for example, if you allocate a space worth 100 elements but when running it only uses 10 - waste of memory. On the other hand, if too less memory is allocate, the program can crash when run due to insufficient memory
Why are dynamic data structures better than static data structures?
They are memory efficient and the number of data items that it can hold is limited only by the overall memory location to the program
What is an example of the dynamic data structure, a linked list, and state it’s advantages and disadvantages
Linked list:
+: size is not predetermined
-: elements cannot be readily accessed directly as they are accessed by memory location rather than index
Where is memory for dynamic data structures taken from? What does this do?
The memory heap - allocated memory for a program at runtime
Define array
Data structure that holds a number of data items/elements of the same type
What index do most languages use when identifying a position in an array?
0
What type of data structure is an array?
A static data structure
What do you need to ensure you refer to when retrieving a particular value from an array?
The correct index
How can you envisage a two dimensional array?
A table with rows and columns
What is another word for a two dimensional array?
Matrix
Which indexes do you need when implementing a two dimensional array
Column index and row index
What order do the indexes for a two dimensional array go in?
Column and then row
How are items positioned in a 3 dimensional array?
Using 3 indexes
What is a field?
A fixed number of variables
What is a record?
A data structure that consists of a fixed number of variables (fields)