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.

Choose a algorithms block below and edit its starter example. In a Markdown document, use the block type as the fence language and the example as its body. Run chiltepin block <type> with your installed CLI for fields and allowed values. See installation for command setup or browse the visual catalog. Descriptions come from the authoring skill.

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 list∅9471prevcurrnext
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: 31—2plum: 9grape: 13—4fig: 7
Legendbucketentrycurrentout of playcollision chain
Valid — passes chiltepin check