Data Structure
A data structure is a group / set / collection of related data items / elements
Data Structure Advantages
Convenient / best way of organising data relating to a real problem
An efficient way to deal with various elements as one item
Data Structure Disadvantage
More Complex to program
Array
2D Array
A 2D array is a grid-like structure which can hold both rows and columns of the same data type.
Record
Linked List
Searching Linked List
UNORDERED
Can’t be terminated until all items have been inspected
ORDERED
Can be terminated when a value greater than search is found
Linked List Advantages
Linked List Disadvantages
Stack
Stack Underflow and Overflow
UNDERFLOW
Attempt to POP an empty stack
OVERFLOW
Attempt to PUSH a full stack
Binary Tree
Binary Tree nodes contain…
Delete a Binary Tree node
DELETE ROOT
Replace root with highest value from left side of tree
1 CHILD
Replace node with child
2 CHILDREN
Replace node with child at left pointer
Pre Order Traversal Use
Clone a tree e.g. make a copy of files in a hierarchical file structure
ROOT -> LEFT -> RIGHT
In Order Traversal Use
Outputting node content in order
LEFT -> ROOT -> RIGHT
Post Order Traversal Use
Deleting all of the node contents
LEFT -> RIGHT -> ROOT
Binary Tree Comparisons with Array and Linked List
ARRAY ADVANTAGE
Faster to search/ add (in order) a value
ARRAY DISADVANTAGE
More complex to program tree
LINKED LIST ADVANTAGE
Faster to access data in tree
LINKED LIST DISADVANTAGE
Binary tree has 2 pointers, list has 1
Hash Table
Hashing Table: Chaining
Hashing Table: Progressive Overflow
Hashing Algorithm: Overflow
Queue