{"id":22455414,"url":"https://github.com/grayvox/ruby-binary-search","last_synced_at":"2025-10-25T00:07:40.050Z","repository":{"id":246579075,"uuid":"820950168","full_name":"Grayvox/ruby-binary-search","owner":"Grayvox","description":"🌲 Binary Search Trees in Ruby","archived":false,"fork":false,"pushed_at":"2024-07-07T20:03:50.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T17:42:09.901Z","etag":null,"topics":["computer-science","ruby","theodinproject"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Grayvox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-27T13:57:17.000Z","updated_at":"2024-07-07T20:03:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"4eaa255e-2109-49c9-8a0c-0e9d2caba2c2","html_url":"https://github.com/Grayvox/ruby-binary-search","commit_stats":null,"previous_names":["grayvox/ruby-binary-search"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grayvox%2Fruby-binary-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grayvox%2Fruby-binary-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grayvox%2Fruby-binary-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grayvox%2Fruby-binary-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Grayvox","download_url":"https://codeload.github.com/Grayvox/ruby-binary-search/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245850361,"owners_count":20682647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-science","ruby","theodinproject"],"created_at":"2024-12-06T07:11:48.391Z","updated_at":"2025-10-25T00:07:39.992Z","avatar_url":"https://github.com/Grayvox.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary Search Tree in Ruby\n\nThis includes both depth-first and breadth-first approaches to searching a BST.\n\nThe following methods are included in this project:\n\n- [x] `#build_tree(array)` -- takes an array of data and returns a balanced tree of `Node` objects, and returns the level 0 root node.\n- [x] `#pretty_print` -- returns a visually pleasing showcase of the tree.\n- [x] `#insert(value)` -- inserts the value provided into the tree, keeping it balanced.\n- [x] `#delete(value)` -- deletes the value provided if it is in the tree, keeping it balanced afterwards. Returns nil if the value is not found.\n- [x] `#find(value)` -- searches through the tree to find the value provided. Returns nil if the value is not found\n- [x] `#level_order(\u0026block)` -- traverses the tree in breadth-first level order and yields each node to the provided block. Returns an array of values if no block is given. Also uses an array acting as a queue to keep track of all the child nodes that it has yet to traverse and will add new ones to the list when needed. This version uses recursion, while `#level_order_iteration(\u0026block)` uses iteration.\n- [x] `#inorder(\u0026block)` -- traverses the tree in depth-first using inorder traversal and yields each node to the provided block. Returns an array of values if no block is given.\n- [x] `#preorder(\u0026block)` -- traverses the tree in depth-first using preorder traversal and yields each node to the provided block. Returns an array of values if no block is given.\n- [x] `#postorder(\u0026block)` -- traverses the tree in depth-first using postorder traversal and yields each node to the provided block. Returns an array of values if no block is given.\n- [x] `#height(value)` -- accepts the value of a node on the tree and returns its height. Height is defined as the number of edges in longest path from a given node to a leaf node. Returns nil if the value isn't found on the tree.\n- [ ] `#depth(value)` -- accepts the value of a node on the tree  and returns its depth. Depth is defined as the number of edges in path from a given node to the tree’s root node. Returns nil if the value isn't found on the tree.\n- [x] `#balanced?` -- checks if the tree is balanced. A balanced tree is one where the difference between heights of left subtree and right subtree of every node is not more than 1. Returns true or fals.\n- [x] `#rebalance` -- rebalances an unbalanced tree.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrayvox%2Fruby-binary-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrayvox%2Fruby-binary-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrayvox%2Fruby-binary-search/lists"}