1/47
Resources: https://github.com/graded-cs-resources/IB-Computer-Science-Notes/tree/main/paper1 https://pbaumgarten.com/ib-compsci/unit-5-data-structures.pdf
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is recursion
A function or method which calls itself
Advantages of recursion
Can reduce time complexity and development time and it can add clarity
What are the applications of queues? (5 implementations)
printer queues 🖨
music playlists 🎶
interrupt handling 🤫
reversing stacks
modelling physical queues
What are the two features of the static implementation of stacks and queues ?
have a maximum capacity
rely on pointers to add and ‘remove’ elements.
Why are dynamic data structures needed ?
They allow dynamic memory allocation so we don't need to declare their size at initialisation.
They don't need contiguous memory locations as they are linked by referencing the address of the next node.
Insert and delete operations are not computationally expensive as they don't require element shifting
How do dynamic data structures enable a dynamic variable size
As each node has a pointer to other nodes, only the pointers need to be changed to add, remove or move a node
Name differences between a static data structure and dynamic data structure
Static structures have a fixed size, dynamic structures have a variable length.
Static structures have declaration-time size allocation, dynamic have runtime size allocation.
Static have random access (indexes), dynamic has sequential access (no indexes).
Static are easier for searching and storing and use less memory.
Dynamic data structures can be more memory efficient overall as the data structure only uses what’s necessary as size will increase or decrease at runtime
Dynamic structures have a possibility of overflow or underflow during runtime if allocations are exceeded. This doesnt happen in static structures as memory size is fixed.
Advantages of a doubly linked list
bidirectional traversal; easier to search in
Disadvantages of doubly linked list
uses more memory in comparison to singly linked list
randomly stored so direct access isn’t allowed (sequential only)
Disadvantages of circular linked list ↻
inserting at the start would be expensive as it requires searching through for the final element; finding the end is hard.
How do you insert a node into the beginning of a list
The pointer of the new head node will point to the previous head node;
The header pointer will point to the new node.
The connection between header node and header pointer is removed
How do you insert a node in to the end of a list
Connect tail node to the new node
The new node will be connected to null (in singly linked list)
Give examples of primitive data types
Double, Integer, Character, Boolean
Applications of stacks
storing recursive calls
implementing function calls
returning memory addresses
translations from one programming language to another
browser history
in calculations and evaluations of expressions.
What are the features of a dynamic data structure?
Pointers.
Each node has a pointer, they don’t need to be placed next to each other.
To delete and insert nodes, only the pointers need to be changed.
Enables their dynamic size.
Disadvantages of a doubly linked list
Uses more memory in comparison to singly linked list
randomly stored so direct access isn’t allowed (sequential only)
What is a subtree in a binary tree
A parent with a child. It can be one or two children.
What is a root in a binary tree
The root is the original node.
what is the base case
a point at which the recursion will stop because the most basic endpoint has been reached, so a simple answer can be given.