Logo

Programming-Idioms

History of Idiom 9 > diff from v36 to v37

Edit summary for version 37 by seigel:
[Ruby] Should also have a place to store the value.

Version 36

2019-09-26, 23:15:58

Version 37

2019-09-26, 23:29:47

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
Node = Struct.new(:left, :right)
parent = Node.new(Node.new, Node.new)
Code
Node = Struct.new(:left, :right, :value)
parent = Node.new(Node.new, Node.new)
Comments bubble
Should also have a place to store the value