{"id":27253438,"url":"https://github.com/marselester/binary-search-tree","last_synced_at":"2025-04-11T01:27:39.738Z","repository":{"id":143042035,"uuid":"145203157","full_name":"marselester/binary-search-tree","owner":"marselester","description":"Binary Search Tree implemented using recursions.","archived":false,"fork":false,"pushed_at":"2018-08-27T12:15:57.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T09:21:51.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/marselester.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":"2018-08-18T08:24:13.000Z","updated_at":"2018-08-18T08:25:26.000Z","dependencies_parsed_at":"2023-04-27T04:45:59.834Z","dependency_job_id":null,"html_url":"https://github.com/marselester/binary-search-tree","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbinary-search-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbinary-search-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbinary-search-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbinary-search-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marselester","download_url":"https://codeload.github.com/marselester/binary-search-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248324233,"owners_count":21084670,"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":[],"created_at":"2025-04-11T01:27:37.848Z","updated_at":"2025-04-11T01:27:39.727Z","avatar_url":"https://github.com/marselester.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary Search Tree\n\n[![Documentation](https://godoc.org/github.com/marselester/binary-search-tree?status.svg)](https://godoc.org/github.com/marselester/binary-search-tree)\n[![Go Report Card](https://goreportcard.com/badge/github.com/marselester/binary-search-tree)](https://goreportcard.com/report/github.com/marselester/binary-search-tree)\n\nBinary Search Tree (BST) is a tree structure where key in a node is larger than the keys in all its **left** children\nand smaller than the keys in **right** children. New nodes are attached at the bottom of the tree.\n\nBST can provide fast search/inserts, and you can get all the keys in order:\n\n1. get all left children (smaller)\n2. get the current key\n3. get all right children (larger).\n\nThose properties can be leveraged in [HastyDB](https://github.com/marselester/hastydb) to implement a memtable,\nthough in practise it's better to use a self-balancing tree such as Red-Black tree.\n\nThe running time depends on the shape of a tree which depends on the order in which keys were inserted.\nLg N is the best case (tree is balanced), e.g., when keys inserted in a random order, so there are no long paths.\nN in the worst case (N nodes in a search path). The worst case scenario happens when keys are inserted in a sorted order.\n\n## Usage Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/marselester/binary-search-tree\"\n)\n\nfunc main() {\n\ttree := bst.Tree{}\n\ttree.Set(\"name\", []byte(\"Bob\"))\n\tfmt.Printf(\"%s\", tree.Get(\"name\"))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbinary-search-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarselester%2Fbinary-search-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbinary-search-tree/lists"}