Class: DSA::BasicBinarySearchTreeNode
- Inherits:
-
Object
- Object
- DSA::BasicBinarySearchTreeNode
- Defined in:
- lib/DSA/binary_search_tree.rb
Overview
A basic binary search tree node
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#left ⇒ Object
Returns the value of attribute left.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#right ⇒ Object
Returns the value of attribute right.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(key, value) ⇒ BasicBinarySearchTreeNode
constructor
A new instance of BasicBinarySearchTreeNode.
Constructor Details
#initialize(key, value) ⇒ BasicBinarySearchTreeNode
Returns a new instance of BasicBinarySearchTreeNode.
5 6 7 8 9 10 11 12 |
# File 'lib/DSA/binary_search_tree.rb', line 5 def initialize(key, value) raise KeyError, 'Key cannot be nil' if key.nil? @key = key @value = value @parent = nil @left = nil @right = nil end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
4 5 6 |
# File 'lib/DSA/binary_search_tree.rb', line 4 def key @key end |
#left ⇒ Object
Returns the value of attribute left.
4 5 6 |
# File 'lib/DSA/binary_search_tree.rb', line 4 def left @left end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/DSA/binary_search_tree.rb', line 4 def parent @parent end |
#right ⇒ Object
Returns the value of attribute right.
4 5 6 |
# File 'lib/DSA/binary_search_tree.rb', line 4 def right @right end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/DSA/binary_search_tree.rb', line 4 def value @value end |