/bs_tree

always 4 fun

Primary LanguageRubyMIT LicenseMIT

BsTree

An implementation of binary tree, just 4 fun :)

Installation

Add this line to your application's Gemfile:

gem 'bs_tree'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bs_tree

Usage

tree root element:

	@root = BsTree::Node.new(5)

and add node:

	@root.insert(10)

or

	[1, 7, 3, 10, 8].each{|x| @root.insert x }

tree sketch

 	 5
   2    7
 1  3     10
        8

DLR traval:

BsTree::Tree.traval(:dlr, @root)

LRD traval:

BsTree::Tree.traval(:lrd, @root)

Contributing

  1. Fork it ( http://github.com//bs_tree/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request