4.2 - Funamentals of data structures Flashcards
What is a static data structure?
A data structure which reserves memory for a set amount of data. Meaning that it has limited capacity for data
What is the advantage of a static array?
They are efficient in terms of being able to access elements directly by index
What are the disadvantages of a static array?
- Memory is wasted if its full capacity isn’t used
- if insufficient space has been allocated, the program may crash or not work properly
What is a dynamic data structure?
A data structure which has a non-fixed memory capacity with the number of data items it can hold only being limited by the overall memory allocation to the program.
What are the advantages of dynamic data structures?
- They are memory efficient
- its size is not predetermined
What is the disadvantage of dynamic data structures?
The elements cannot be readily accessed directly by index but rather sequentially by memory location
What is a queue?
An abstract data type that holds an ordered linear sequence of items in the form FIFO
How is the order of a queue kept?
A pointer is maintained at the front to indicate the element in the front of the queue and a pointer is maintained at the rear to identify the last item in the queue
What is an abstract data type?
An abstract data type is the building blocks of a data type/data structure, defining the behaviour and properties of it, without specifying its implementation.
What is a concrete data type?
A concrete data type provides a specific implementation of the abstract data type that determines how the data is stored and accessed in memory.
What is a data type?
A data type specifies the format of the data and the range of values that can be assigned to it. It defines the set of operations that can be performed on the data and the rules for performing these operations.
What is a data structure?
A data structure defines the way data is organized and stored in memory. It specifies how the individual data items are related to each other and how they can be accessed and manipulated efficiently.
What is a priority queue?
A queue where each item inserted into the queue is given a certain level of priority. That item is put in from of all items of a lower priority but ahead of those of higher priority.
What are the main operations on a queue?
enqueue(data) - adds an element to the queue
dequeue() - returns an element from the front of the queue
is_empty() - check whether the queue is empty
is_full() - check whether the (static only) queue is at maximum capacity
Difference between abstract data type and concrete data type?
An abstract data type is the framework of the data type, for example a stack is a first in last out data structure and has functions such as pop and append related to it. Whereas a concrete data type is the implementation of the abstraction, for example the stack can be implemented using an array.
Examples of data types?
Integer: used to represent whole numbers
Float: used to represent decimal numbers
Boolean: used to represent true/false values
Character: used to represent single letters or symbols
String: used to represent a sequence of characters
Examples of data structures?
Array: a collection of data items of the same type, stored in contiguous memory locations
Linked List: a collection of nodes, each containing data and a reference to the next node in the sequence
Queue: a data structure that allows access to only the oldest added item, using the First-In-First-Out (FIFO) principle
Tree: a hierarchical data structure consisting of nodes, with a single root node and zero or more child nodes at each level
What is a linear queue?
A queue stored in an array where, as more items are enqueued and dequeued, the pointers move up the array.
It is limited by the length of the array in which it is stored, so the end of the array will eventually be reached if elements are not constantly moved up to the start of the array which can be time consuming.
What is a circular queue?
A queue which reuses the empty slots at the front of the array when elements are removed from the queue. When the rear pointer reaches the last position of the array, it wraps back round to the start of the array. The front pointer moves similarly as items are dequeued.
What is a graph?
An abstract data type that can be used to represent complex, non-linear relationships between objects.
What are records?
Records are a type of data structure containing several fields used to store data. Each field within a record is usually identified by a name, and the data in each field can be of different types, such as numbers, strings, or dates.