{"id":13482323,"url":"https://github.com/johnjansen/ternary_search_tree","last_synced_at":"2026-03-10T14:36:11.325Z","repository":{"id":71329320,"uuid":"95918223","full_name":"johnjansen/ternary_search_tree","owner":"johnjansen","description":"A Crystal implementation of a Ternary Search Tree","archived":false,"fork":false,"pushed_at":"2017-07-07T04:02:50.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T16:39:50.241Z","etag":null,"topics":["crystal","datastructure","tree"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnjansen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-30T19:32:51.000Z","updated_at":"2021-11-12T12:35:31.000Z","dependencies_parsed_at":"2023-03-06T07:00:24.962Z","dependency_job_id":null,"html_url":"https://github.com/johnjansen/ternary_search_tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnjansen%2Fternary_search_tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnjansen%2Fternary_search_tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnjansen%2Fternary_search_tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnjansen%2Fternary_search_tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnjansen","download_url":"https://codeload.github.com/johnjansen/ternary_search_tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245854323,"owners_count":20683333,"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":["crystal","datastructure","tree"],"created_at":"2024-07-31T17:01:00.876Z","updated_at":"2026-03-10T14:36:11.276Z","avatar_url":"https://github.com/johnjansen.png","language":"Crystal","funding_links":[],"categories":["Algorithms and Data structures"],"sub_categories":[],"readme":"# Ternary Search Tree - (pure crystal-lang)\n\n[![GitHub version](https://badge.fury.io/gh/johnjansen%2Fternary_search_tree.svg)](http://badge.fury.io/gh/johnjansen%2Fternary_search_tree)\n[![CI](https://travis-ci.org/johnjansen/ternary_search_tree.svg?branch=master)](https://travis-ci.org/johnjansen/ternary_search_tree)\n\nIn computer science, a ternary search tree is a type of trie (sometimes called a prefix tree) where nodes are arranged in a manner similar to a binary search tree, but with up to three children rather than the binary tree's limit of two. Like other prefix trees, a ternary search tree can be used as an associative map structure with the ability for incremental string search. However, ternary search trees are more space efficient compared to standard prefix trees, at the cost of speed. Common applications for ternary search trees include spell-checking and auto-completion. (wikipedia)\n\nFurthur considerations from [Hackthology](http://hackthology.com/ternary-search-tries-for-fast-flexible-string-search-part-1.html)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  ternary_search:\n    github: johnjansen/ternary_search\n```\n\n## Usage\n\n```crystal\nrequire \"ternary_search\"\n\ntst = TernarySearch::Tree.new\n\n# add to the TST\ntst.insert(\"polygon\")  # =\u003e nil\ntst.insert(\"triangle\") # =\u003e nil\n\n# search the TST\ntst.search(\"polygon\")  # =\u003e true\ntst.search(\"poly\")     # =\u003e false\ntst.search(\"triangle\") # =\u003e true\n\n# get the max word length\ntst.max_word_length # =\u003e 8\n\n# get an array of words in the TST\n# DO NOT USE THIS ON LARGE TST's\n# i'm looking into a block version of this!\ntst.words = [\"polygon\", \"triangle\"]\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/johnjansen/ternary_search/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [johnjansen](https://github.com/johnjansen) John Jansen - creator, maintainer\n- [RX14](https://github.com/RX14) Chris Hobbs - rewriter, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnjansen%2Fternary_search_tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnjansen%2Fternary_search_tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnjansen%2Fternary_search_tree/lists"}