Skip to content
chiltepin
chiltepin docs
Blocks reference

Algorithms

When to use each of the 4 algorithms blocks, with a live example of every one.

The algorithms blocks: what each one is for, how to choose between neighbours, and a live starter example you can edit — converted at build time from the authoring skill your agent reads. Every example body is YAML; in a real doc the fence language is the block type (for example sequence … ). Schemas are strict — unknown fields are rejected. The full field contract for any block — every field, enum, and terse one-line form, generated from the schema — is npx chiltepin block <type>. See the block catalog for every block rendered on one page.

Shape: Structure & emphasis — one data structure frozen at one step (array, linkedlist, bintree, hashmap). One step per block; freeze a moment, don't animate. Answers: What does the structure hold at this step, and where do the pointers stand? Not this family: graph algorithms (BFS / DFS / Dijkstra) → graph with node state + edge weight (charts-overviews.md); a file hierarchy → tree (charts-overviews.md); control flow → flow (flows.md).

Algorithms & data structures

All four blocks share one tone enum: active is the element under examination, visited is processed, target is the goal, muted is out of play. Quote numeric values (value: "19"); they are strings.

array — array cells for algorithm walkthroughs

A row of square cells, indices above, pointer labels (lo, mid) below. Answers: where do the pointers stand at this step? window outlines a 0-based inclusive index range. array, not table, for binary search, two pointers, and sliding windows; table for tabular data.

```arrayeditable · live
renderedchiltepin renders this
SECTION 01 · Array

Binary search — step 2

ARRAY
Array0317212319427541lomidhisearch space
Legendcellcurrenttargetvisited[ ]window
Valid — passes chiltepin check

linkedlist — pointer-chain diagram

Boxed nodes joined by arrows; the chain ends in a ground symbol. Answers: which node does each pointer hold during a reversal or insertion? kind: doubly adds a back-arrow per link. Pointer labels render above. linkedlist, not flow, for pointer manipulation; flow for control flow.

```linkedlisteditable · live
renderedchiltepin renders this
SECTION 01 · Linked list

Reversing a list — step 2

LIST
Linked list9471prevcurrnext
Legendnodecurrentvisitednext
Valid — passes chiltepin check

bintree — binary tree

Nodes placed by parent and side; a parent centres over its children, so an unbalanced chain slants. Answers: which path does a search or traversal take? Every node with a parent must set side. Two children on one side is a schema error. Several parentless nodes draw as side-by-side roots (rotations). bintree, not tree, for BSTs, heaps, and traversals; tree for file hierarchies.

```bintreeeditable · live
renderedchiltepin renders this
SECTION 01 · Binary tree

BST search for 27

TREE
Binary tree198312740
Legendnodecurrenttargetvisited
Valid — passes chiltepin check

hashmap — buckets + chained entries

A column of bucket slots; entries in one bucket chain rightward in entry order. Answers: where does each key land, and which keys collide? An entry whose bucket is outside 0..buckets-1 is skipped, not clamped. The render caps at 12 buckets; keep the count readable. hashmap, not table, for hashing and collision walkthroughs; table for a plain key-value listing.

```hashmapeditable · live
renderedchiltepin renders this
SECTION 01 · Hash map

Chained hash table

HASH
Hash map0apple: 312plum: 9grape: 134fig: 7
Legendbucketentrycurrentout of playcollision chain
Valid — passes chiltepin check