{"id":15490680,"url":"https://github.com/theodesp/go-heaps","last_synced_at":"2025-10-04T12:38:51.035Z","repository":{"id":33785158,"uuid":"150794096","full_name":"theodesp/go-heaps","owner":"theodesp","description":"Reference implementations of heap data structures in Go - treap, skew, leftlist, pairing, fibonacci","archived":false,"fork":false,"pushed_at":"2022-08-17T11:27:17.000Z","size":190,"stargazers_count":97,"open_issues_count":15,"forks_count":29,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-19T09:19:49.549Z","etag":null,"topics":["2-3-heap","data-structures","fibonacci-heap","go","heaps","leftlist-heap","pairing-heap","rank-pairing-heap","skew-heap","treap"],"latest_commit_sha":null,"homepage":"","language":"Go","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/theodesp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-28T21:00:15.000Z","updated_at":"2024-09-30T10:01:26.000Z","dependencies_parsed_at":"2022-08-07T23:01:03.436Z","dependency_job_id":null,"html_url":"https://github.com/theodesp/go-heaps","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/theodesp%2Fgo-heaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-heaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-heaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-heaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/go-heaps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251784840,"owners_count":21643368,"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":["2-3-heap","data-structures","fibonacci-heap","go","heaps","leftlist-heap","pairing-heap","rank-pairing-heap","skew-heap","treap"],"created_at":"2024-10-02T07:23:18.808Z","updated_at":"2025-10-04T12:38:45.986Z","avatar_url":"https://github.com/theodesp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-heaps\n[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors)\n---\n\u003ca href=\"https://godoc.org/github.com/theodesp/go-heaps\"\u003e\n\u003cimg src=\"https://godoc.org/github.com/theodesp/go-heaps?status.svg\" alt=\"GoDoc\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg\" alt=\"License\"/\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://travis-ci.org/theodesp/go-heaps\" rel=\"nofollow\"\u003e\n\u003cimg src=\"https://travis-ci.org/theodesp/go-heaps.svg?branch=master\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/theodesp/go-heaps\"\u003e\n  \u003cimg src=\"https://codecov.io/gh/theodesp/go-heaps/branch/master/graph/badge.svg\" /\u003e\n\u003c/a\u003e\n\nReference implementations of heap data structures in Go\n\n## Installation\n```bash\n$ go get -u github.com/theodesp/go-heaps\n```\n\n## Contents\n\n**Heaps**\n\n* [Pairing Heap](https://en.wikipedia.org/wiki/Pairing_heap): A pairing heap is a type of heap data structure with relatively simple implementation and excellent practical amortized performance.\n* [Leftist Heap](https://www.geeksforgeeks.org/leftist-tree-leftist-heap/): a variant of a binary heap. Every node has an s-value which is the distance to the nearest leaf. In contrast to a binary heap, a leftist tree attempts to be very unbalanced.\n* [Skew Heap](https://en.wikipedia.org/wiki/Skew_heap): A skew heap (or self-adjusting heap) is a heap data structure implemented as a binary tree. Skew heaps are advantageous because of their ability to merge more quickly than binary heaps.\n* [Fibonacci Heap](https://en.wikipedia.org/wiki/Fibonacci_heap): a Fibonacci heap is a data structure for priority queue operations, consisting of a collection of heap-ordered trees. It has a better amortized running time than many other priority queue data structures including the binary heap and binomial heap.\n* [Binomial Heap](https://www.geeksforgeeks.org/binomial-heap-2/): A Binomial Heap is a collection of Binomial Trees. A Binomial Heap is a set of Binomial Trees where each Binomial Tree follows Min Heap property. And there can be at most one Binomial Tree of any degree.\n* [Treap Heap](https://en.wikipedia.org/wiki/Treap): A Treap and the randomized binary search tree are two closely related forms of binary search tree data structures that maintain a dynamic set of ordered keys and allow binary searches among the keys.\n* [Rank Pairing Heap](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.153.4644\u0026rep=rep1\u0026type=pdf): A heap (priority queue) implementation that combines the asymptotic efficiency of Fibonacci heaps with much of the simplicity of pairing heaps\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"github.com/theodesp/go-heaps\"\n\tpairingHeap \"github.com/theodesp/go-heaps/pairing\"\n\t\"fmt\"\n)\n\nfunc main()  {\n\theap := pairingHeap.New()\n\theap.Insert(go_heaps.Integer(4))\n\theap.Insert(go_heaps.Integer(3))\n\theap.Insert(go_heaps.Integer(2))\n\theap.Insert(go_heaps.Integer(5))\n\n\tfmt.Println(heap.DeleteMin()) // 2\n\tfmt.Println(heap.DeleteMin()) // 3\n\tfmt.Println(heap.DeleteMin()) // 4\n\tfmt.Println(heap.DeleteMin()) // 5\n}\n\n```\n\n## Complexity\n| Operation     | Pairing       | Leftist      | Skew          | Fibonacci     | Binomial      | Treap         |\n| ------------- |:-------------:|:-------------:|:-------------:|:-------------:|:-------------:|:-------------:|\n| FindMin       | Θ(1)          | Θ(1)          | Θ(1)          | Θ(1)\t\t\t| Θ(log n)      | O(n)          |\n| DeleteMin     | O(log n)      | O(log n)      | O(log n)      | O(log n)\t    | Θ(log n)      | O(n)          |\n| Insert        | Θ(1)          | O(log n)      | O(log n)      | Θ(1)\t\t\t| Θ(1)          | O(n)          |\n| Find          | O(n)          |               |               |\t\t\t\t|               |               |    \n| Delete        | O(n)          |               | O(log n)      | O(n)\t\t\t| Θ(log n)      | O(n)          |\n| Adjust        | O(n)          |               | O(log n)      | O(n) \t\t\t| Θ(log n)      | O(n)          |\n| Meld          | Θ(1)          |               |               |               |               |               |\n\n| Operation     | Rank Pairing  | \n| ------------- |:-------------:|\n| FindMin       | Θ(1)          |\n| DeleteMin     | O(log n)      | \n| Insert        | Θ(1)          | \n| Find          | O(n)          |     \n| Delete        | O(n)          |             \n| Adjust        | O(n)          |\n| Meld          | Θ(1)          |\n\n\n\n## Contributors\n\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n\u003ctable\u003e\u003ctr\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"http://mb-14.github.io\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/1137632?v=4\" width=\"100px;\" alt=\"Miroojin Bakshi\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMiroojin Bakshi\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=mb-14\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://syfaro.net\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/1369709?v=4\" width=\"100px;\" alt=\"Syfaro\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSyfaro\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=Syfaro\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/theodesp\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/328805?v=4\" width=\"100px;\" alt=\"Theofanis Despoudis\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eTheofanis Despoudis\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=theodesp\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://www.linkedin.com/in/ignacy-radlinski\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/26116041?v=4\" width=\"100px;\" alt=\"Radliński Ignacy\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRadliński Ignacy\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=radlinskii\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/DonMcNamara\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1152286?v=4\" width=\"100px;\" alt=\"Don McNamara\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDon McNamara\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#infra-DonMcNamara\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://koneko096.github.io/\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/9217338?v=4\" width=\"100px;\" alt=\"Afrizal Fikri\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAfrizal Fikri\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=koneko096\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/lhauspie\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/25682509?v=4\" width=\"100px;\" alt=\"Logan HAUSPIE\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eLogan HAUSPIE\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=lhauspie\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://ejq.me/\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/5517838?v=4\" width=\"100px;\" alt=\"Song Guo\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSong Guo\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=erjiaqing\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/safwan-moha\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/7314967?v=4\" width=\"100px;\" alt=\"Safwan Mohammed\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSafwan Mohammed\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=safwan-moha\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"https://github.com/theodesp/go-heaps/commits?author=safwan-moha\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n\n\n## LICENCE\nCopyright © 2017 Theo Despoudis MIT license","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-heaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Fgo-heaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-heaps/lists"}