class BinaryDecisionTree::Tree

Attributes

depth[R]

Public Class Methods

new(depth, node_class: Node) click to toggle source
# File lib/binary_decision_tree/tree.rb, line 5
def initialize(depth, node_class: Node)
  @depth = depth
  @nodes = Array.new(size) {|i| i == 0 ? nil : node_class.new(self, i)}
end

Public Instance Methods

at(position) click to toggle source
# File lib/binary_decision_tree/tree.rb, line 14
def at(position)
  @nodes[position]
end
root() click to toggle source
# File lib/binary_decision_tree/tree.rb, line 10
def root
  @nodes[1]
end
size() click to toggle source
# File lib/binary_decision_tree/tree.rb, line 18
def size
  2**depth
end