We create a linked list region and place the head pointer at position 0 — this is the only entry point for traversal.

Linked List


Adding node_1 with value 10 — the head pointer starts here, making it the first node we visit in the traversal.

We create a linked list region and place the head pointer at position 0 — this is the only entry point for traversal.


We add node_2 with value 20 and link it from node_1 via a next pointer — following these next links is how we traverse the list.

add_node[node_2], add_edge[node_1,node_2], set_role[node_1], set_role[node_2], move_pointer[head]

Adding node_1 with value 10 — the head pointer starts here, making it the first node we visit in the traversal.


Finally node_3 with value 30 has no next link — this null terminator marks it as the tail, ending our traversal.

add_node[node_3], add_edge[node_2,node_3], set_role[node_2], set_role[node_3], annotate[node_3]

We add node_2 with value 20 and link it from node_1 via a next pointer — following these next links is how we traverse the list.

tail (null next)


The traversal is complete — we visited every node from head to tail by following next pointers.

Finally node_3 with value 30 has no next link — this null terminator marks it as the tail, ending our traversal.


Setting up the linked list with a head pointer.

List


Adding the next two nodes and connecting them.

add_node[n2], add_node[n3], add_edge[n1,n2], add_edge[n2,n3]

Setting up the linked list with a head pointer.


The tail node has no next pointer, traversal ends here.

Adding the next two nodes and connecting them.

tail


add_node[a], add_node[b], add_node[c], add_edge[a,b], add_edge[b,c]


We set up a stack region with a container — stacks follow Last In First Out order, so we'll use ordered=false.

Stack


Push A onto the stack — A becomes the new top. Then push B on top of A, so B is now the top element.

add_node[A], push_to[stack,A], add_node[B], push_to[stack,B], move_pointer[top]

We set up a stack region with a container — stacks follow Last In First Out order, so we'll use ordered=false.


Pop removes B — the most recently pushed element — revealing A underneath. This is the LIFO property in action.

Push A onto the stack — A becomes the new top. Then push B on top of A, so B is now the top element.


Push C on top — the stack now holds [A, C] with C as the new top, confirming LIFO order throughout.

Pop removes B — the most recently pushed element — revealing A underneath. This is the LIFO property in action.


Creating a stack region with a container and top pointer.

Stack


Push A and B onto the stack, B is now on top.

add_node[A], push_to[stack,A], add_node[B], push_to[stack,B]

Creating a stack region with a container and top pointer.


Pop B, then push C. Stack ends as [A, C] demonstrating LIFO.

Push A and B onto the stack, B is now on top.


add_region[stk], add_container[stack], add_node[A], push_to[stack,A], add_node[B]

Stack


We initialize BFS by creating a queue and seeding it with source A — BFS always begins from a single starting node.

add_region[bfs_region], add_container[q], push_to[q,A], set_role[A]

BFS Queue


Dequeue A from the queue and mark it visited — we then push A's unvisited neighbors B and C as frontier nodes.

pop_from[q], set_role[A], push_to[q,B], push_to[q,C], set_role[B], set_role[C]

We initialize BFS by creating a queue and seeding it with source A — BFS always begins from a single starting node.


Dequeue B and visit it — B's neighbor D joins the frontier, demonstrating BFS level-by-level order.

pop_from[q], set_role[B], push_to[q,D], set_role[D]

Dequeue A from the queue and mark it visited — we then push A's unvisited neighbors B and C as frontier nodes.


Dequeue C and visit it — C connects to D and E, but D is already in the queue so only E is added.

pop_from[q], set_role[C], push_to[q,E], set_role[E]

Dequeue B and visit it — B's neighbor D joins the frontier, demonstrating BFS level-by-level order.


All nodes are now visited in BFS order A,B,C,D,E — each level was fully processed before moving deeper.

pop_from[q], set_role[D], pop_from[q], set_role[E]

Dequeue C and visit it — C connects to D and E, but D is already in the queue so only E is added.


Create a BFS queue and enqueue source node A, marking it as frontier.

BFS Queue


Dequeue A, visit it, and enqueue neighbors B and C.

pop_from[q], set_role[A], push_to[q,B], push_to[q,C]

Create a BFS queue and enqueue source node A, marking it as frontier.


Process B then C, adding D and E to the queue as we go.

pop_from[q], set_role[B], push_to[q,D], pop_from[q], set_role[C], push_to[q,E]

Dequeue A, visit it, and enqueue neighbors B and C.


D and E are dequeued and visited, finishing BFS traversal.

Process B then C, adding D and E to the queue as we go.


add_region[bfs_region], add_container[q], set_role[A], set_role[B], set_role[C]

BFS


set_role[A], set_role[B], set_role[C], set_role[D], set_role[E]


Initialize Dijkstra by creating a priority queue and distance table — source A gets distance 0, all others start at infinity.

add_region[pq_region], add_container[pq], push_to[pq,A], annotate[A], set_role[A]

Priority Queue


Extract A (d=0) from the priority queue — Dijkstra guarantees this distance is final. Relax edges to B and C: d[B]=1, d[C]=4.

pop_from[pq], set_role[A], set_value[B], annotate[B], push_to[pq,B], set_value[C]

Initialize Dijkstra by creating a priority queue and distance table — source A gets distance 0, all others start at infinity.


Extract B (d=1) — its shortest distance is now permanent. Relaxing B's edges: d[C] improves from 4 to 3 via B, and d[D]=6.

pop_from[pq], set_role[B], annotate[B], set_value[C], annotate[C], push_to[pq,C]

Extract A (d=0) from the priority queue — Dijkstra guarantees this distance is final. Relax edges to B and C: d[B]=1, d[C]=4.

d=1 final


Extract C (d=3), relax to D: d[D] improves to 4. Then D is extracted with final distance 4. All shortest paths found.

pop_from[pq], set_role[C], set_value[D], annotate[D], set_role[D]

Extract B (d=1) — its shortest distance is now permanent. Relaxing B's edges: d[C] improves from 4 to 3 via B, and d[D]=6.


Set up a priority queue for Dijkstra and initialize source A with distance 0.

add_region[pq_region], add_container[pq], push_to[pq,A], annotate[A]

PQ


Extract A, relax edges to B (d=1) and C (d=4). Then extract B, improve C to d=3.

pop_from[pq], set_role[A], set_value[B], push_to[pq,B], set_value[C]

Set up a priority queue for Dijkstra and initialize source A with distance 0.


Extract B, update C's distance to 3 via B. Push C into the queue.

pop_from[pq], set_role[B], set_value[C], push_to[pq,C]

Extract A, relax edges to B (d=1) and C (d=4). Then extract B, improve C to d=3.


Extract C, relax D to distance 4. All shortest paths computed.

pop_from[pq], set_role[C], set_value[D], set_role[D]

Extract B, update C's distance to 3 via B. Push C into the queue.


add_region[pq_region], add_container[pq], set_role[A], set_role[B], set_value[D]

PQ


Create a tree region and insert 5 as the root node — the first key always becomes the root of the BST.

BST


Insert 3: comparing with root 5, 3 < 5 so it goes left — this maintains the BST invariant where left children are smaller.

Create a tree region and insert 5 as the root node — the first key always becomes the root of the BST.


Insert 7: comparing with root 5, 7 > 5 so it goes right — the right subtree holds all keys greater than the parent.

Insert 3: comparing with root 5, 3 < 5 so it goes left — this maintains the BST invariant where left children are smaller.


Insert 2 and 4: recursively comparing, 2 < 3 goes left of n3, and 4 > 3 goes right of n3.

add_node[n2], add_edge[n3,n2], add_node[n4], add_edge[n3,n4]

Insert 7: comparing with root 5, 7 > 5 so it goes right — the right subtree holds all keys greater than the parent.


Insert 8: 8 > 5 go right, 8 > 7 go right — each insertion recursively finds the correct leaf position.

Insert 2 and 4: recursively comparing, 2 < 3 goes left of n3, and 4 > 3 goes right of n3.


Create a BST tree region and insert 5 as root.

BST


Insert 3 left of 5 and 7 right of 5, maintaining BST invariant.

add_node[n3], add_edge[n5,n3], add_node[n7], add_edge[n5,n7]

Create a BST tree region and insert 5 as root.


Recursively insert 2 left of 3 and 4 right of 3.

Insert 3 left of 5 and 7 right of 5, maintaining BST invariant.


Insert 8 right of 7 to complete the BST.

Recursively insert 2 left of 3 and 4 right of 3.


add_region[tree], add_node[n5], add_node[n3], add_edge[n5,n3], add_node[n7], add_edge[n5,n7]

BST