Peter Brachwitz
78 followers
78 followers
Posts
Post has attachment
99 Clojure Problems – 64: Layout a Binary Tree (1)
"Given a binary tree as defined before being either a vector of the form [v l r] or nil.
As a preparation for drawing the tree, a layout algorithm is required to
determine the position of each node in a rectangular grid. In this
layout strategy, the ...
Post has attachment
Post has attachment
99 Clojure Problems – 63: Construct a Complete Binary Tree
"A complete binary tree with height H is defined as follows: The levels 1,2,3,...,H-1 contain the maximum number of nodes (i.e 2(i-1) at the level i, note that we start counting the levels from 1 at the root). In level H, which may contain less than the max...
Post has attachment
The 1939–40 New York World's Fair
World Fair
vimeo.com
Post has attachment
Post has attachment
99 Clojure Problems – 62B: Collect the Nodes at a Given Level in a List.
"A node of a binary tree is at level N if the path from the root to the
node has length N-1. The root node is at level 1. Write a method
at-level to collect all nodes at a given level in a list." (deftest p62b-at-level
(is (= '(b c) (at-level '[a [b n...
Post has attachment
99 Clojure Problems – 61A: Collect the Leaves of a Binary Tree in a List
"61A (*) Collect the leaves of a binary tree in a list.
A leaf is a node with no successors. Write a method leaves to
collect them in a list." (deftest p61a-leaves
(is (= '(b d e) (leaves '[a [b nil nil] [c [d nil nil] [e nil nil]]])))) A variation on...
Post has attachment
99 Clojure Problems – 62: Collect the Internal Nodes of Binary Tree in a List
"An internal node of a binary tree has either one or two non-empty successors. Write a method internals to collect them in a list." (deftest p62-internals
(is (= '(a c) (internals '[a [b nil nil] [c [d nil nil] [e nil nil]]])))) I used the same idea as in...