Fundamentals of Data Structures Flashcards
What is a queue?
A FIFO (First in, first out) data structure
What is a stack?
A LIFO (Last in, first out) data structure
What’s a graph?
A data structure made up of nodes which have a cyclical structure
What is a tree?
A data structure made up of nodes which isn’t cyclical.
Usually hierarchical.
The top level is known as the “root node”
The bottom level nodes are known as “leaf nodes”
What is a hash table?
A data structure where a hash function is used to mark the position in the table where data should be stored.
This allows us to access data directly rather than a search
What is a dictionary?
A collection of key-value pairs in which the value is accessible via the associated key
What is a dynamic data structure?
A data structure that changes in size to store their contents.
What is a static data structure?
A method of storing data where the amount of data stored (and memory used t store it) is fixed
Discuss the advantages and disadvantages of dynamic data structures compared to static data structures.
Advantages of dynamic:
There’s no wasted memory, static allocates at creation dynamic allocates as it’s needed.
No limit on the number of items which can be added, static has a finite/fixed limit.
Disadvantages of dynamic:
Can take longer to add a new item to the structure, because it has to allocate memory.
Can cause a memory leak, if memory that’s no longer needed isn’t returned to the heap
What is a linear queue?
Organised as a list or line of data
Describe the steps involved in adding an item to a linear queue that has been implemented as a static data structure using an array
Check that the queue is not already full;
(if it isn’t) then add 1 to the value of the rear pointer; [increment address]
then add the new item to the position indicated by the rear pointer;
What is a priority queue?
Queue where each item has a priority, and items are kept sorted with the highest priority item in front (priority is signified as subscript numbers)
What is a circular queue?
The last node is connected back to the first node in nature
Its static; has a limited number of elements
What is meant by the term ‘push’?
A process which adds an item to a data structure typically to a stack.
What is meant by the term ‘pop’?
A process which removes an item from a data structure typically from a stack.
What is meant by the term ‘peek’?
A process which allows you to inspect a data structure and returns the item at the front or top without removing it.
What is a weighted graph?
A graph in which each edge has a value associated with it
What is an Adjacency Matrix used for?
To represent a graph by listing each node and indicating where there is an edge between pairs.