Computer Science Data Structures
Animora includes nine stateful data structures (animora.datastructures) designed for computer science education. Each structure pairs a pure Python data model (XModel) with an animation generation layer (X).
1. Supported Structures
Array(ArrayListModel): Linear indexed sequence withanimate_swap(),animate_highlight(),animate_set().Stack(StackModel): LIFO stack withanimate_push(),animate_pop(),animate_peek().Queue(QueueModel): FIFO queue withanimate_enqueue(),animate_dequeue(),animate_peek().LinkedList(LinkedListModel): Singly-linked list with pointer transitions (animate_insert_tail()).Heap(HeapModel): Binary min-heap with sift-up/sift-down animations.Tree(GenericTreeModel): N-ary tree positioned via Phase 4TreeLayout.BST(BSTModel): Binary search tree with path-traced insertions and full 3-case deletion (leaf, 1-child, 2-children).Graph(GraphModel): Network positioned viaGraphLayoutwith state primitives (animate_highlight_node(),animate_mark_visited(),animate_highlight_edge()).HashTable(HashTableChainingModel): Hash table using Separate Chaining collision handling.
2. Usage Example: Binary Search Tree
from animora.core import Scene
from animora.datastructures import BST
class BSTDemo(Scene):
def construct(self) -> None:
bst = BST([50, 30, 70, 20, 40])
self.play(bst.animate_create())
# Traverses [50, 30, 40] before placing 35:
self.play(bst.animate_insert(35))
# Search highlight:
self.play(bst.animate_search(35))
# Complete 2-children deletion with in-order successor:
self.play(bst.animate_delete(30))