- Nodes & a pointer
- Dynamic data structure
Data and a pointer to the next node
Where an extra pointer is added so that node can point ot the previous and next item
Where the last node points to the first. To circle through the list.
Where an extra pointer is added to the previous item
- ISR routines
- Playlists (music players)
- Image viewers to switch between previous and next image
- Hash table collisions resolution as an overflow
- Linear search through them
- Move to the previous item (doubly linked list)
- Delete nodes
- Add nodes
- A data structure consisting of nodes/vertices & pointers/edges.
- Each vertex can have more than 2 edges
Directed - Points in one direction
Undirected - Doesn't have a specified direction
Where each edge is given a value showin the relationship between vertices
Objects or Dictionaries known as adjacent lists
- Convenient to work with
- Adding edges are very simple
Disadvantages:
- Graphs with many nodes and few edges leaveempty cells
- Larger graphs waste more memory
- Using static structures e.g. arrays makes it harder to add/delete nodes
Mapping road networks for navigation systems
Storing social network data
resource allocation
Breadth-first search - uses queues (FIFO) structure. Start with the root node, dequeue the root node and explore its adjacent nodes. Repeat when going to next node (any order)
Depth-first search - uses stacks (LIFO) structure. Visited nodes are pushed onto the stack.
- When there are no nodes left to visit, the last node is popped off the stack
- Pre-Order traversal
- In-Order traversal
- Post-Order traversal
- Check if there's free memory for a new node, output error if not
- Create new node & insert data
- if the list is empty, new node becomes first node (put a satrt pointer on it)
- If the new node should be placed before the 1st node, put a start pointer on the new node and point it to that node
- If the new node is greater than the current node check the next node until you find the correct position
- update the free pointer so it points to the next available storage space
- Check if list is empty, if empty output error
- If first item to be deleted, set start pointer to next node & delete
- Start at node 1 & traverse if current node is to be deleted, set pointer from previous to next node
- update free pointer
- Check if empty
- Start at node with starter pointer
- output item
- Go to next node
- repeat last 2 steps until item found
A data sturcture used to hold an ordered sequence (Can be both static or dynamic)