{"id":34041458,"url":"https://github.com/cool-pot/pytrees","last_synced_at":"2026-04-07T17:31:41.551Z","repository":{"id":57458023,"uuid":"133979362","full_name":"cool-pot/pytrees","owner":"cool-pot","description":"python3 implementation of trees. Including AVL Tree, Interval Tree and More.","archived":false,"fork":false,"pushed_at":"2018-05-21T17:28:36.000Z","size":59,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T14:22:58.440Z","etag":null,"topics":["avl-tree","binary-indexted-tree","binary-search-tree","interval-tree","python3","trie"],"latest_commit_sha":null,"homepage":"","language":"Python","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/cool-pot.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}},"created_at":"2018-05-18T16:32:29.000Z","updated_at":"2025-03-09T14:25:19.000Z","dependencies_parsed_at":"2022-09-06T14:41:09.348Z","dependency_job_id":null,"html_url":"https://github.com/cool-pot/pytrees","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cool-pot/pytrees","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-pot%2Fpytrees","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-pot%2Fpytrees/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-pot%2Fpytrees/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-pot%2Fpytrees/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cool-pot","download_url":"https://codeload.github.com/cool-pot/pytrees/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-pot%2Fpytrees/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31522246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["avl-tree","binary-indexted-tree","binary-search-tree","interval-tree","python3","trie"],"created_at":"2025-12-13T22:02:55.318Z","updated_at":"2026-04-07T17:31:41.541Z","avatar_url":"https://github.com/cool-pot.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytrees\n![](https://img.shields.io/badge/LICENSE-MIT-green.svg)\n![](https://img.shields.io/badge/python-python3-color.svg)\n\nA collection of python3 implementations of trees. Including AVL Tree, Interval Tree and More.\n\n## Install\n\n~~~ shell\npip3 install pytrees \n~~~\n\n## Usage\n\n~~~python\n\u003e\u003e\u003e from pytrees import AVLTree, IntervalTree, BinaryIndexTree, Trie\n\n\u003e\u003e\u003e avl = AVLTree.buildFromList([-1,-2,1,2,3,4,5,6])\n\u003e\u003e\u003e avl.visulize()\n~~~\n~~~ bash\n-----------------Visualize Tree----------------------\n         2\n      -1  5\n   -2  1  3  6\n               4      \n-----------------End Visualization-------------------\n~~~\n~~~ python\n\u003e\u003e\u003e avl.delete(4)\n\u003e\u003e\u003e avl.visulize()\n~~~\n~~~ bash\n-----------------Visualize Tree----------------------\n      2\n   -1  5\n-2  1  3  6\n-----------------End Visualization-------------------\n~~~\n~~~python\n\u003e\u003e\u003e avl.insert(0)\n\u003e\u003e\u003e avl.visulize()\n~~~\n~~~ bash\n-----------------Visualize Tree----------------------\n         2\n      -1  5\n   -2  1  3  6\n      0               \n-----------------End Visualization-------------------\n~~~\n\n## Classes\n\n### AVL Tree\n\nAVL Tree. \nBalanced Binary Search Tree. Gurantee for balance.\n\nAPI:\n\n- insert(self, val)\n- delete(self, key)\n- search(self, key)\n- getDepth(self)\n- preOrder(self)\n- inOrder(self)\n- postOrder(self)\n- countNodes(self)\n- buildFromList(cls, l)\n\n### Interval Tree\n\nAugmented data structure for checking overlaps of intervals. Gurantee for balance.\n\nAPI:\n\n- queryOverlap(self, val)\n- queryAllOverlaps(self, val)\n- insert(self, val)\n- delete(self, key)\n- search(self, key)\n- getDepth(self)\n- preOrder(self)\n- inOrder(self)\n- postOrder(self)\n- countNodes(self)\n- buildFromList(cls, l)\n\n### Binary Search Tree\n\nSimple implementation of Binary Search Tree. No gurantee for balance.\n\n\nAPI:\n\n- insert(self, val)\n- delete(self, key)\n- search(self, key)\n- getDepth(self)\n- preOrder(self)\n- inOrder(self)\n- postOrder(self)\n- countNodes(self)\n- buildFromList(cls, l)\n\n### Trie (Prefix-Tree)\n\nPrefix-tree. Useful for text search.\n\nAPI: \n\n- insert(self, word)\n- search(self, word)\n- startsWith(self, prefix)\n- findAllWordsStartsWith(self, prefix)\n- buildFromList(cls, l)\n\n### Binary Index Tree\n\nA Fenwick tree or Binary Indexed Tree is a data structure that can efficiently update elements and calculate prefix sums in a table of numbers.\n\nAPI: \n\n- update(self,i,k)  --\u003e update value k to index i\n- prefixSum(self,i) --\u003e sum up [index 0, index 1, ..., index i]\n- preview(self) \n- getSize(self)\n- buildFromList(cls, l)\n\nTime Complexity: update \u0026 prefixSum, O(logN)\n\nSpace Complexity: O(N)\n\n## Convention: \n\n- \"key\" and \"val\" are almost the same in this implementation. use term \"key\" for search and delete a particular node. use term \"val\" for other cases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcool-pot%2Fpytrees","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcool-pot%2Fpytrees","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcool-pot%2Fpytrees/lists"}