Last active
June 25, 2018 08:50
-
-
Save guillaumebihet/70712a1cc4f7718db6831dbd7bdcc4bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tree | |
attr_accessor :payload, :children | |
def initialize(payload, children) | |
@payload = payload | |
@children = children | |
end | |
end | |
#The "Leafs" of the tree, elements that have no children | |
deep_fifth_node = Tree.new(5,[]) | |
eighth_node = Tree.new(8, []) | |
fourth_node = Tree.new(4, []) | |
#The "Branches"of the tree | |
ninth_node = Tree.new(9, [fourth_node]) | |
sixth_node = Tree.new(6, [deep_fifth_node, eighth_node]) | |
seventh_node = Tree.new(7, [sixth_node]) | |
shallow_fifth_node = Tree.new(5, [ninth_node]) | |
#The "Trunk" of the tree | |
trunk = Tree.new(2, [seventh_node, shallow_fifth_node]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment