ApasScript.

Data Structures

These are Apas Cloud services: they run on our servers for a signed-in member. The examples below are shown already made; sign in to edit and run your own.

linkedList Apas Cloud

Creates a singly linked list, optionally filled from an array (front to back). Shows as boxes with next-pointers; pushFront/pushBack/insertAt/removeAt/remove/search/reverse/traverse animate each step.

stack Apas Cloud

Creates a stack (last in, first out), optionally filled from an array (bottom to top). push/pop/peek animate; popping an empty stack shows an underflow step.

queue Apas Cloud

Creates a CIRCULAR queue with a fixed capacity (1-64): front and rear indices wrap around the slot array. enqueue/dequeue/peek animate; enqueueing into a full queue shows the overflow.

hashTable Apas Cloud

Creates a hash set of integer keys with h(k) = k mod m, using separate chaining (default) or linear probing ("linear", with tombstones on removal). Grows to 2m+1 buckets and rehashes when the load factor would exceed maxLoad (default 1 for chaining, 0.75 for linear).

bst Apas Cloud

Creates a binary search tree, optionally inserting an array's values in order. insert/remove/search/traverse animate the comparisons ("4 < 5: go left"); removing a node with two children uses its in-order successor.

avl Apas Cloud

Creates a self-balancing AVL tree: like bst(), but every insert/remove rebalances with single or double rotations, each shown as its own step. Nodes show their balance factor.

minHeap Apas Cloud

Creates a binary min-heap (smallest value at the root), built from an array with bottom-up heapify. Drawn as a tree with its array underneath; push/pop/peek animate each compare and swap.

maxHeap Apas Cloud

Creates a binary max-heap (largest value at the root) -- same as minHeap() with the order reversed.

push Apas Cloud

Pushes a value onto a stack or heap (sift-up animated); on a queue it enqueues, on a tree it inserts. Returns the step-by-step animation.

pop Apas Cloud

Removes and animates taking the top of a stack, the root of a heap (last element moved up, then sift-down), or the front of a queue.

peek Apas Cloud

Highlights the element pop() would take next (stack top, queue front, heap root) without removing it.

enqueue Apas Cloud

Adds a value at the rear of a circular queue, showing the rear index wrap around.

dequeue Apas Cloud

Removes the front value of a circular queue, showing the front index advance (and wrap).

pushFront Apas Cloud

Links a new node in at the head of a linked list.

pushBack Apas Cloud

Appends a node at the tail of a linked list -- the walk from the head to the tail is shown step by step (a singly linked list has no tail pointer).

insertAt Apas Cloud

Inserts a value so it ends up at position i (0 = front) of a linked list, walking to the node before it.

removeAt Apas Cloud

Unlinks the node at position i (0 = front) of a linked list.

insert Apas Cloud

Inserts a value into a BST/AVL tree (compare path, then any rotations), a hash table (h(k), probing/chaining), a heap (sift-up), a linked list (at the back) or a stack/queue.

remove Apas Cloud

Removes a value from a BST/AVL tree (leaf, one-child and two-child cases), a hash table (a tombstone under linear probing) or a linked list (first match).

reverse Apas Cloud

Reverses a linked list in place with the three-pointer method: the boxes stay put while each next-pointer flips, one step at a time.

traverse Apas Cloud

Walks a tree in "inorder" (default), "preorder", "postorder" or "levelorder" order -- numbering each node as it is visited and building the output list -- or walks a linked list front to back.

toArray Apas Cloud

The structure's values as an ordinary array: list front to back, stack bottom to top, queue front to rear, tree in-order, heap in array order, hash table in bucket order.

size Apas Cloud

How many values the structure holds.

height Apas Cloud

Height of a BST/AVL tree (a single node has height 1, an empty tree 0).