Logo

Programming-Idioms

History of Idiom 9 > diff from v25 to v26

Edit summary for version 26 by programming-idioms.org:
[Elixir] No need for sample values. +DemoURL

Version 25

2016-12-04, 22:16:42

Version 26

2017-02-07, 23:33:49

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}}
Code
defmodule BinaryTree do
	defstruct data: nil, left: nil, right: nil
end
Demo URL
http://play.elixirbyexample.com/s/bf451110f2