{"id":25171780,"url":"https://github.com/basemax/binarytreego","last_synced_at":"2025-07-01T12:03:55.073Z","repository":{"id":64857969,"uuid":"577304841","full_name":"BaseMax/BinaryTreeGo","owner":"BaseMax","description":"Implementation of a binary tree in Go. A Binary Tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. A node with no children is called a leaf node. A node cannot have more than two children.","archived":false,"fork":false,"pushed_at":"2022-12-16T09:21:53.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-26T18:56:45.293Z","etag":null,"topics":["algorithm","algorithms","algorithms-and-data-structures","algorithms-datastructures","binary-tree","data-structure","datastructure","ds","go","golang","tree","tree-algorithms","tree-binary","tree-data-structure","tree-search","tree-structure"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.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":"2022-12-12T12:52:53.000Z","updated_at":"2022-12-16T10:33:34.000Z","dependencies_parsed_at":"2022-12-17T00:36:28.154Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/BinaryTreeGo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BaseMax/BinaryTreeGo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBinaryTreeGo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBinaryTreeGo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBinaryTreeGo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBinaryTreeGo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/BinaryTreeGo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FBinaryTreeGo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262959563,"owners_count":23391057,"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":["algorithm","algorithms","algorithms-and-data-structures","algorithms-datastructures","binary-tree","data-structure","datastructure","ds","go","golang","tree","tree-algorithms","tree-binary","tree-data-structure","tree-search","tree-structure"],"created_at":"2025-02-09T09:22:04.297Z","updated_at":"2025-07-01T12:03:55.013Z","avatar_url":"https://github.com/BaseMax.png","language":"Go","readme":"# Binary-Tree Go\r\n\r\nImplementation of a binary tree in Go. A Binary Tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. A node with no children is called a leaf node. A node cannot have more than two children.\r\n\r\n## Structure\r\n\r\n**Types:**\r\n```go\r\n// Type for storing a node of a binary tree\r\ntype Node struct {\r\n\tValue interface{}\r\n\tLeft  *Node\r\n\tRight *Node\r\n}\r\n\r\n// Type for storing a binary tree\r\ntype GeneralTree struct {\r\n\tRoot *Node\r\n}\r\n```\r\n\r\n**Functions:**\r\n\r\n- `func NewNode(value interface{}) *Node`: Create a new node\r\n- `func NewGeneralTree() *GeneralTree`: Create a new binary tree\r\n- `func NewGeneralTreeWithNumbers(values ...interface{}) *GeneralTree`: Create a new tree and insert the given values (in order, root, left and right), number of arguments in the function is not limited\r\n\r\n**Methods:**\r\n\r\n```go\r\n// Insert a new node into the binary tree\r\nfunc (tree *GeneralTree) Insert(value interface{})\r\nfunc (node *Node) Insert(value interface{})\r\n\r\n// Insert a new node into left side of the binary tree\r\nfunc (tree *GeneralTree) InsertLeft(value interface{})\r\nfunc (node *Node) InsertLeft(value interface{})\r\n\r\n// Insert a new node into right side of the binary tree\r\nfunc (tree *GeneralTree) InsertRight(value interface{})\r\nfunc (node *Node) InsertRight(value interface{})\r\n\r\n// Search a node in the binary tree\r\nfunc (tree *GeneralTree) Search(value interface{}) *Node\r\nfunc (node *Node) Search(value interface{}) *Node\r\n\r\n// Find the first value in the binary tree\r\nfunc (tree *GeneralTree) FindFirst() *Node\r\nfunc (node *Node) FindFirst() *Node\r\n\r\n// Find the last value in the binary tree\r\nfunc (tree *GeneralTree) FindLast() *Node\r\nfunc (node *Node) FindLast() *Node\r\n\r\n\t// Find the height of the binary tree\r\nfunc (tree *GeneralTree) Height() int\r\nfunc (node *Node) Height() int\r\n\r\n\t// Find the depth of the binary tree\r\nfunc (tree *GeneralTree) Depth() int\r\nfunc (node *Node) Depth() int\r\n\r\n\t// Find the number of nodes in the binary tree\r\nfunc (tree *GeneralTree) Size() int\r\nfunc (node *Node) Size() int\r\n\r\n\t// Find the number of leaves in the binary tree\r\nfunc (tree *GeneralTree) Leaves() int\r\nfunc (node *Node) Leaves() int\r\n\r\n\t// Find the number of full nodes in the binary tree\r\nfunc (tree *GeneralTree) FullNodes() int\r\nfunc (node *Node) FullNodes() int\r\n\r\n// Find the number of half nodes in the binary tree\r\nfunc (tree *GeneralTree) HalfNodes() int\r\nfunc (node *Node) HalfNodes() int\r\n\r\n// Find the number of nodes in the binary tree\r\nfunc (tree *GeneralTree) Nodes() int\r\nfunc (node *Node) Nodes() int\r\n\r\n// Find the level of a node in the binary tree\r\nfunc (tree *GeneralTree) Level(value interface{}) int\r\nfunc (node *Node) Level(value interface{}) int\r\n\r\n// Find the parent of a node in the binary tree\r\nfunc (tree *GeneralTree) Parent(value interface{}) *Node\r\nfunc (node *Node) Parent(value interface{}) *Node\r\n\r\n// Find the sibling of a node in the binary tree\r\nfunc (tree *GeneralTree) Sibling(value interface{}) *Node\r\nfunc (node *Node) Sibling(value interface{}) *Node\r\n\r\n// Find the uncle of a node in the binary tree\r\nfunc (tree *GeneralTree) Uncle(value interface{}) *Node\r\nfunc (node *Node) Uncle(value interface{}) *Node\r\n\r\n// Find the number of nodes in the binary tree\r\nfunc (tree *GeneralTree) Count() int\r\nfunc (node *Node) Count() int\r\n\r\n// Print the binary tree in pre-order\r\nfunc (tree *GeneralTree) PreOrder()\r\nfunc (node *Node) PreOrder()\r\n\r\n// Print the binary tree in in-order\r\nfunc (tree *GeneralTree) InOrder()\r\nfunc (node *Node) InOrder()\r\n\r\n// Print the binary tree in post-order\r\nfunc (tree *GeneralTree) PostOrder()\r\nfunc (node *Node) PostOrder()\r\n\r\n// Print the binary tree in level-order\r\nfunc (tree *GeneralTree) LevelOrder()\r\nfunc (node *Node) LevelOrder()\r\n\r\n// Print the binary tree in reverse level-order\r\nfunc (tree *GeneralTree) ReverseLevelOrder()\r\nfunc (node *Node) ReverseLevelOrder()\r\n\r\n// Print the binary tree in spiral order\r\nfunc (tree *GeneralTree) SpiralOrder()\r\nfunc (node *Node) SpiralOrder()\r\n\r\n// Print the binary tree in zig-zag order\r\nfunc (tree *GeneralTree) ZigZagOrder()\r\nfunc (node *Node) ZigZagOrder()\r\n\r\n// Print the binary tree in vertical order\r\nfunc (tree *GeneralTree) VerticalOrder()\r\nfunc (node *Node) VerticalOrder()\r\n\r\n// Print the binary tree in reverse-vertical order\r\nfunc (tree *GeneralTree) ReverseVerticalOrder()\r\nfunc (node *Node) ReverseVerticalOrder()\r\n\r\n// Print the binary tree in diagonal order\r\nfunc (tree *GeneralTree) DiagonalOrder()\r\nfunc (node *Node) DiagonalOrder()\r\n\r\n// Print the binary tree in reverse-diagonal order\r\nfunc (tree *GeneralTree) ReverseDiagonalOrder()\r\nfunc (node *Node) ReverseDiagonalOrder()\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the GPL-3.0 License - see the [LICENSE](LICENSE) file for details.\r\n\r\n© Copyright (c) 2022, Max Base\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fbinarytreego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Fbinarytreego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Fbinarytreego/lists"}