Logo

Programming-Idioms

History of Idiom 9 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-09-05, 10:53:24

Version 9

2015-09-05, 15:30:44

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
defmodule BinaryTree do
	defstruct data: nil, left: nil, right: nil
end

%BinaryTree{data: 5, left: %BinaryTree{data: 2}, right: %BinaryTree{data: 10}}