BINARY SEARCH TREE EXPLORER — native Squeak lab Published 2026-10-19 What this kit contains ---------------------- Eight cumulative runnable checkpoints, a final native Morphic app, 54 application SUnit tests, two exercise solutions with 12 tests, exact lesson text and launchers, eight native window screenshots, a scripted native GIF with original frames, and scripts to rebuild and replay the deliverables. Runtime ------- Verified in Squeak 6.1, 64-bit update 23976. Morphic and SUnit are bundled. No additional Smalltalk package, browser runtime, network service or timer is used. The Squeak VM and image are not bundled; supply your own matching distribution. A matching .changes file and the distribution's .sources files should accompany the image. The replay copies the image and changes into a private temporary folder, links the source files for lookup, runs with null display/sound, and never saves it. Install and launch interactively ------------------------------- 1. Work in a copy of your learning image. 2. In Squeak's File List, select examples/search-tree-final.st and choose fileIn. Whole .st files use chunk format. Do not paste them into a Workspace. 3. In a Workspace, evaluate: LSBSTApp open 4. Press Sample 20/40/60, enter 30, and press Insert. 5. Press Start find and Step to compare one node at a time. 6. Use In-order, Validate and Reset. Close the window when finished. Each search-tree-01.st through search-tree-08.st contains its complete source. Install the selected checkpoint in a fresh image copy and run the exact launcher from search-tree.json. Going backwards by file-in alone will not remove methods introduced in a later checkpoint. The source file defines classes without opening a window. Close the previous application before installing another checkpoint. Model and controls ------------------ LSBSTNode owns value, left and right. LSBinarySearchTree owns root and operation state. LSBSTApp controls native buttons and text input; LSBSTPanel draws the model. LSBSTWindow fixes the window size to keep the teaching diagram readable. The model accepts distinct integers from -99 to 99. It rejects duplicates, non-integers, a tenth node, or an insertion below depth four (root depth zero). Rejected insertion returns false and leaves node links unchanged. A successful insert returns true and clears search and traversal results. Insertion order matters: ascending values make a chain and reach the depth bound with five nodes. There is no deletion or balancing operation in this lesson. Type a decimal integer with an optional minus sign. Insert, Find and Start find read pending native editor text directly. Expressions and decimal fractions are rejected. -1 and +1 use the most recently accepted value and clamp to -99..99. Start find stores a target; changing the field afterward does not alter that active target. Start find again to change it. Step after completion is a no-op. Orange means a compared node, gold means the next comparison, green means found. From stage seven, edges show L/R references and clicking a card selects its actual object with a purple outline. Clicking blank space clears selection. Inserting can move cards while preserving selection identity. Reset clears everything and returns input to 30. Sample replaces the reachable tree with the three-node fixture. find: answers the actual node or nil. inOrder answers a new sorted Array, or nil when structural validation fails. An empty traversal is #(), distinct from nil. The model exposes node references for Inspector learning. Node setters bypass its guards; use a disposable model for deliberate corruption. A tree may be changed through low-level setters between search steps, but that is outside the supported search flow: reset or start a new search after Inspector experiments. Reset drops root, so externally held old nodes are not destroyed. Run native tests interactively ------------------------------ After filing in the final source, file in examples/search-tree-tests.st. In a Workspace, Print it: LSBSTTest suite run Expected: 54 runs, 54 passes, zero failures and errors. Then file in examples/search-tree-exercise-1.st, examples/search-tree-exercise-2.st and examples/search-tree-exercise-tests.st. Print it: LSBSTExerciseTest suite run Expected: 12 runs, 12 passes, zero failures and errors. Exercise height counts levels: empty 0, leaf 1. valuesBetween:and: returns an inclusive sorted interval, using the BST comparisons to prune subtrees. Automated replay from this extracted folder ------------------------------------------- Python 3 and Pillow are required for the full replay. Pillow only encodes GIF; tests and PNG capture need Python 3 and the supplied Squeak distribution. Use absolute paths for the VM and image. For example on Linux: python scripts/run_native.py --vm /path/to/Squeak/bin/squeak --image /path/to/Squeak/shared/Squeak6.1-23976-64bit.image --task all Tasks: tests, stages, gifs, all. The runner uses -vm-display-null and -vm-sound-null, so it does not touch a shared desktop or display. Expected all output: 54 application passes; 12 exercise passes; exact exercise snippet results; eight checkpoint OK reports; 24 native replay PNG frames. The encoded GIF contains 22 distinct frames because the GIF encoder coalesces two repeated identical states. Playback is 1.1 seconds per source state, with coalesced states retaining their combined duration. The runner overwrites only this kit's generated results, screenshots, frames and runtime-scripts. It removes old report files and relevant PNG outputs before launch so an old successful result cannot mask a failed native run. It can be run repeatedly with bundled media and reports already present. The .image file you supply remains unchanged. A syntax error in edited source may open a native compiler notification instead of completing; the subprocess timeout reports that failure rather than accepting an old output. Rebuild source/content files ---------------------------- python scripts/build_sources.py python scripts/build_tests.py python scripts/build_content.py These scripts regenerate examples and search-tree.json. Rerun native verification after changing them. package.py creates downloads/search-tree-lab.zip and a SHA-256 manifest. Source and content generators are included to keep accepted methods, complete checkpoints and prose snippets aligned. Capture provenance and scope ---------------------------- media/search-tree-stage-01.png through -08.png are real SystemWindow imageForm captures after each exact launcher and every highlighted Browser method has been compiled. They are not browser mockups or manually redrawn cards. media/search-tree-operations.gif is a scripted native replay, not a recording of a person. scripts/run_native.py sends MouseButtonEvent down/up events to native buttons and sets text through PluggableTextMorph. It also sends a native mouse event to select a node. Each state is captured with PNGReadWriter from imageForm. Original frames live in frames/. results/gif-capture.txt records the model states. results/gif-verification.json records frame hashes and the encoded count. Pillow performs palette conversion and timing only; it does not paint application state. The common palette is sampled from every frame. Exact ordinary, compared, next, found and selected colors are reserved and verified after decoding the final GIF. The explorer is deliberately bounded and unbalanced. Whole-tree safety checks add work before commands, so this is not a benchmark of production BST complexity. The visual layout uses in-order rank and depth and is not a general layout engine. No search process runs between button clicks, and no cleanup beyond closing the window is required. Keep the source files to reconstruct the app in a clean image.