What are data structures
Data structures is a format used to store , organise, modify and access data
What are the features of an array
An indexed set of related elements
Must be finite and indexed
An array often start from zero
Must only contain elements with the same data type
what are Queues
how can they be used
FIFO ( First item added is the first to be removed )
Used in keyboard buffers and breadth first search algorithm
Liner queues
It has two pointers ( front and rear)
IsEmpty , IsFull , Enqueue and Dequeue
How can emptiness in a queue be detected
By comparing the front and rear pointers
Why is a circular queue better than a linear queue
It is more memory efficient
What is a circular queue
A type of queue where the front and rear pointers can move over the two ends of the queue
What are priority queues
Items are assigned a priority
High priority items are dequeued first before lower priority items
What happens when two or more items have the same priority
Items are removed in first in first out
What are the features of stacks
It has a pointer
Push
Pop
Peek
IsFull and IsEmpty
What happens when a push command is executed on a full stack
A stack overflow is thrown
What happens when you use the pop command on an empty stack
Stack underflow
When can a graph be used
Can be used to represent networks such as transport networks, IT networks and the
Internet.
What does a graph consist of
Consists of nodes (sometimes called vertices) joined by edges (sometimes called
arcs)
What is a weighted graph
A weighted graph is one in which edges are assigned a value
What are the ways a graph can be represented as
○ Adjacency matrices
○ Adjacency lists
What is a adjacency matrices
● A tabular representation of a graph
● Each of the nodes in the graph is assigned both a row and a column
What is a adjacency lists
● Represent a graph using a list
● For each node, a list of adjacent nodes is created
● Only records existing connections in a graph
What is the difference adjacency matrix ad an adjacency list
Adjacency matrix
Stores every possible edge between
nodes, even those that don’t exist. Almost half of the matrix is repeated data.
Memory inefficient
Allows a specific edge to be queried very
quickly, as it can be looked up by its row
and column.
Time efficient.
Well suited for dense graphs where there are a large number of edges
Adjacency list
Only stores the edges that exist in the
graph.
Memory efficient.
Slow to query, as each item in a list must
be searched sequentially until the desired
edge is found.
Time inefficient.
Well suited to sparse graphs, where there
are few edges.
What are trees
They are connected , undirected with no cycles
What are rooted trees
● The root node is the only node with no parent, all other roots stem from them
What is a leaf node
child nodes with no children
What is a binary node
A rooted tree in which each parent node has no more than two child nodes.
What are hash tables
A hashing algorithm takes an input and returns a hash.A hash table stores key-value pairs