Walking the Tree.

It’s just fun playing around with Stern-Brocot trees and a bit of Haskell…! For any fraction on the Stern-Brocot tree there is just one path to it from the root. That path can written as a sequence of left or right ‘turns’ at each node depending on whether the target node is smaller or larger than the current node. This leads to the Stern Path For example in this small tree the path to, say, 4/5 is, from 1/1, LRRR. The fraction 5/2 has path RRL. To get to 5/8 we go LRLR… and so on. (If you want to Read More

A Stern Tree

The purpose of this post is to show how to generate a visual representation of the Stern-Brocot tree, like this: SBTree the rendering of which uses Northwood’s GoJS Javascript library. To create to a rendered Stern-Brocot tree we need to: Create a binary tree datatype with supporting functions. Generate a specific type of binary tree – i.e. a Stern-Brocot tree. Examine the GoJS model details and write some Haskell to map the binary tree to the Javascript. Binary Trees Yes, I could have found an existing Haskell library for binary trees – but really, where’s the fun in that? A Read More

ˆ Back To Top