What is a stack frame
Stack frames are used to store information about running a program. This is used as a call stack when running programs as it can be used when a subroutine is running to call functions and pass parameters and arguments.
What is a stack?
A data structure that follows the LIFO (Last In, First Out) principle.
What are common stack operations?
push, pop, peek/top, isEmpty.
Example of stack use?
Undo/redo in editors, function call management (call stack).
How is a stack implemented?
Using arrays or linked lists.
What is a queue?
A data structure that follows the FIFO (First In, First Out) principle.
Common queue operations?
Enqueue, dequeue, isEmpty, peek/front.
What is a linear queue?
It is a FIFO structure organised as a line of data such as a list. The max size of this type of queue is fixed in this case. can be dynamic though
What is a circular queue?
A queue that wraps around to reuse empty slots when the end is reached.
What is a priority queue?
A priority queue adds a further element to the queue which is the apriority of each item.
Example of queue use?
Print spooling, task scheduling, buffering in networks.
What is a graph?
A collection of nodes (vertices) connected by edges.
Difference between directed and undirected graphs?
Directed edges have a direction; undirected edges don’t.
Difference between weighted and unweighted graphs?
Weighted graphs have numerical values (weights) on edges.
Ways to represent graphs?
Adjacency list (sparse) or adjacency matrix (dense).
Graph applications?
Social networks, maps, routing.
Difference between an adjacency list and a matrix?
List: Only stores data where there is an edge, so it takes up less space. The list has to be passed to check for agencies, so it takes more time. Where there is fewer edges, lists are better.
Matrix: Stores a value for every combination of node adjacencies so it requires more memory. Adjacency can be identified more quickly as every combo is already stored. Acts as a look-up table. Where there are many adges this method would be more suitable where there are more edges
What is a hash table?
A structure that maps keys to values using a hash function.
What is a hash function?
A function that converts a key into an index in an array.
What is a collision?
When two keys map to the same index.
Collision resolution methods?
Linear probing, chaining (linked lists), rehashing.
Example use of hash tables?
Symbol tables in compilers, caching, Python dictionaries.
What is a dictionary in computing?
A collection of key–value pairs, where each key is unique.
How are dictionaries implemented?
Often as hash tables.