Class: TreeNode

Inherits:
Object
  • Object
show all
Defined in:
lib/binary_trees.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val = 0, left = nil, right = nil) ⇒ TreeNode

Returns a new instance of TreeNode.



16
17
18
19
20
# File 'lib/binary_trees.rb', line 16

def initialize(val = 0, left = nil, right = nil)
  @val = val
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



14
15
16
# File 'lib/binary_trees.rb', line 14

def left
  @left
end

#rightObject

Returns the value of attribute right.



14
15
16
# File 'lib/binary_trees.rb', line 14

def right
  @right
end

#valObject

Returns the value of attribute val.



14
15
16
# File 'lib/binary_trees.rb', line 14

def val
  @val
end