Skip to content

Instantly share code, notes, and snippets.

@andrewsouthard1
Created May 15, 2017 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsouthard1/698c15d6b41ae9f988f5e8af5c9f9e28 to your computer and use it in GitHub Desktop.
Save andrewsouthard1/698c15d6b41ae9f988f5e8af5c9f9e28 to your computer and use it in GitHub Desktop.
Binary Tree Class
class BinaryTreeNode
attr_accessor :value
attr_reader :left, :right
def initialize(value)
@value = value
@right = nil
@left = nil
end
def insert_right(value)
@right = BinaryTreeNode.new(value)
end
def insert_left(value)
@left = BinaryTreeNode.new(value)
end
end
a = BinaryTreeNode.new(5)
a.insert_left(3)
a.insert_right(9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment