1.4.2 Data Structures Flashcards
What is an array?
An ordered, finite set of elements of a single type
What is meant by a 1D array?
A linear array
What is meant by a 2D array?
Visualised as a table/spreadsheet
What is meant by a 3D array?
Visualised as a multi-page spreadsheet
What is a record?
A row in a database
Made up of fields
What is a list?
A finite, ordered set of elements
Items can occur more than once
How are lists initialised?
With square brackets
What is a tuple?
An ordered set of values of any data type
How are tuples initialised?
With regular brackets
Are static data structures mutable or immutable?
Immutable
Are dynamic data structures mutable or immutable?
Mutable
What does immutable mean?
Size of a structure is defined at run-time and cannot change
What does mutable mean?
Size of a structure is defined at run-time and is able to change
Which data structures are static?
Arrays
Stacks
Queues
Trees
Which data structures are dynamic?
Lists
Linked lists
Trees
Hash tables
What is a linked list?
Holds an ordered sequence
Describe how linked lists are stored.
Items do not have to be in contiguous data locations
Each node contains a data field & a link or pointer field
What is the data field of a node?
Actual data associated with list
What is the pointer field of a node?
Address of the next item in list
What is a graph?
Set of vertices/nodes connected by edges/arcs
What is a directed graph?
Edges can only be traversed in one direction
What is an undirected graph?
Edges can be traversed in both directions
What is a weighted graph?
Each edge has a cost attached
How are graphs implemented?
Adjacency matrix or adjaceny list
Give 2 advantages of using an adjacency matrix.
Convenient to work with
Easy to add nodes
Give an advantage of using an adjacency list.
Space efficient for large sparse networks
What is a stack?
A Last In First Out data structure
Can be implemented as static or dynamic
What are stacks used for?
Reversing actions