Logo

Programming-Idioms

History of Idiom 9 > diff from v27 to v28

Edit summary for version 28 by Kng:
New Lua implementation by user [Kng]

Version 27

2017-06-12, 15:33:41

Version 28

2018-04-03, 08:21:39

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Idiom #9 Create a Binary Tree data structure

The structure must be recursive because left child and right child are binary trees too. A node has access to children nodes, but not to its parent.

Code
local function BinTree(v, l, r)
	return {
		val = v,
		left = l,
		right = r
	}
end