Giter Club home page Giter Club logo

binary-tree's Introduction

This project implements a binary tree class and a class to draw the binary tree in Ruby.

Class BinaryTree implements the binary tree and its basic operations (adding nodes, removing nodes, and walking the tree)

Class BinaryTreeDrawer implements the code to "draw" the binary tree. This class does not draw the tree per-se but rather calculates the coordinates where each node should be drawn and calls a specified block to do the actual drawing.


CAN I SEE THIS CODE IN ACTION?
------------------------------
I am glad you asked! Point your browser to http://binarytree.heroku.com to see this code in action.


STARTING WITH THE SOURCE CODE
-----------------------------
* Take a look at the code samples under the samples folder. They include basic examples on how to create a binary tree, add/remove nodes, perform searches, and how to use the drawer class.

* lib\binarytree.rb has the binary tree implementation.

* lib\binarytreedrawer.rb has the code to draw the tree.

* The unit tests under tests are also another good place to start.


A MORE COMPREHENSIVE EXAMPLE
----------------------------
The web site at http://binarytree.heroku.com is a more comprehensive sample of usage. This site used HTML 5's canvas element to actually draw the binary tree on a web page.

The code for this web site is also on this git repository. Run web_server.rb to get it running on your local environment. You'll need Sinatra to run this web site on your box, though. 


EVEN MORE INFORMATION
---------------------
Check out this blog post for more details on how the binary tree, the binary tree drawer, and the demo web site work: http://hectorcorrea.com/Blog/Drawing-a-Binary-Tree-in-Ruby


COMMENTS, THOUGHTS, SUGGESTIONS?
--------------------------------
This is my first Ruby program so very likely it does not follow Ruby's best practices or the Ruby way of doing things but it's a start. 

Feel free to comment and/or reach me if you have any questions, comments, or suggestions.

Hector Correa
[email protected] 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.