feat(viz): tree/BFS/DFS patterns

This commit is contained in:
2025-09-01 20:49:11 +01:00
parent 99741d481b
commit eb21fc7435
13 changed files with 2119 additions and 1 deletions

View File

@@ -82,6 +82,10 @@ export interface DataState {
linkedListPointers?: LinkedListPointerState[];
// Stack support
stacks?: StackState[];
// Tree support
trees?: BinaryTreeState[];
// Queue support
queues?: QueueState[];
}
/** Single step in the visualization */
@@ -203,3 +207,42 @@ export interface StackState {
elements: StackElementState[];
label?: string;
}
// ============================================
// Binary Tree Types
// ============================================
/** State of a binary tree node */
export interface BinaryTreeNodeState {
id: string;
value: number;
state: 'normal' | 'current' | 'visiting' | 'visited' | 'highlighted';
left: string | null;
right: string | null;
}
/** Complete binary tree state */
export interface BinaryTreeState {
id: string;
nodes: BinaryTreeNodeState[];
rootId: string;
label?: string;
}
// ============================================
// Queue Types
// ============================================
/** State of a queue element */
export interface QueueElementState {
id: string;
value: number | string;
state: 'normal' | 'highlighted' | 'enqueued' | 'dequeued';
}
/** Complete queue state */
export interface QueueState {
id: string;
elements: QueueElementState[];
label?: string;
}