0.0
No commit activity in last 3 years
No release in over 3 years
In Order Traversal , Pre Order Traversal , Post Order Traversal,Breadth First Traversal , Deep Search Traversal
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
>= 0
~> 10.0
~> 3.0
 Project Readme

YmDataTree

Coverage Status Build Status Gem Version

Installation

gem 'ym_data_tree'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install ym_data_tree

Usage

In Order/ Post Order / Pre Order Traversal Example

  require 'ym_data_tree'
  tree = YmDataTree::Tree.new
  datas = [10,6,8,5,12,11,15]
  datas.each do |data|
    tree.insert(data)
  end
  #Then Traverse The Tree
  tree.traverse(tree.root,:in_order_traversal)
  #->[5,6,8,10,11,12,15]

  tree.traverse(tree.root,:pre_order_traversal)
  #->[10,6,5,8,12,11,15]

  tree.traverse(tree.root,:post_order_traversal)

  #->[5,8,6,11,15,12]

Breadth First Traversal

require 'ym_data_tree'
tree = YmDataTree::Tree.new
datas =  [10,6,8,5,12,11,15]
datas.each do |data|
  tree.insert(data)
end

tree.traverse(tree.root,:breadth_first_traversal)
#->[10, 6, 12, 5, 8, 11, 15]

Deep First Traversal

require 'ym_data_tree'
tree = YmDataTree::Tree.new
datas =  [10,6,8,5,12,11,15]
datas.each do |data|
  tree.insert(data)
end

tree.traverse(tree.root,:deep_first_traversal,:pre_order_traversal)
#->  [6, 5, 8, 10, 12, 11, 15]

tree.traverse(tree.root,:deep_first_traversal,:in_order_traversal)
 #-> [5, 6, 8, 10, 11, 12, 15]

tree.traverse(tree.root,:deep_first_traversal,:post_order_traversal)

#->[5, 8, 6, 10, 11, 15, 12]

Contributing

Bug reports and pull requests are at https://github.com/ismetsezer/ym_data_tree.

License

The gem is available as open source under the terms of the MIT License.