{"id":21657406,"url":"https://github.com/aliakseis/rb_avl_comparison","last_synced_at":"2026-02-17T15:02:37.388Z","repository":{"id":93559611,"uuid":"51207585","full_name":"aliakseis/rb_avl_comparison","owner":"aliakseis","description":"Comparing RB and AVL tree implementations. We Need To Go Deeper.","archived":false,"fork":false,"pushed_at":"2025-02-04T14:59:33.000Z","size":38,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T20:51:13.792Z","etag":null,"topics":["avl","avl-implementations","avl-tree","avl-tree-implementations","avl-tree-node","balanced-binary-search-trees","binary-search-tree","data-structures","rb-avl","tagged-pointers","tree","tree-insert"],"latest_commit_sha":null,"homepage":"","language":"C","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/aliakseis.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":"2016-02-06T15:24:10.000Z","updated_at":"2025-02-04T14:59:37.000Z","dependencies_parsed_at":"2023-03-12T22:00:14.638Z","dependency_job_id":null,"html_url":"https://github.com/aliakseis/rb_avl_comparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aliakseis/rb_avl_comparison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliakseis%2Frb_avl_comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliakseis%2Frb_avl_comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliakseis%2Frb_avl_comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliakseis%2Frb_avl_comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliakseis","download_url":"https://codeload.github.com/aliakseis/rb_avl_comparison/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliakseis%2Frb_avl_comparison/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29548201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"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","avl-implementations","avl-tree","avl-tree-implementations","avl-tree-node","balanced-binary-search-trees","binary-search-tree","data-structures","rb-avl","tagged-pointers","tree","tree-insert"],"created_at":"2024-11-25T09:21:29.422Z","updated_at":"2026-02-17T15:02:37.373Z","avatar_url":"https://github.com/aliakseis.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rb_avl_comparison\n### Comparing RB and AVL implementations\n\n![trump_family](https://user-images.githubusercontent.com/11851670/56092402-5db11c80-5ec4-11e9-84f1-94e1d643a09f.jpg)\n\nMake AVL Trees Great Again announcement\n\n\"I think I have discovered something that no one else has any idea about, and I’m not sure I can do it justice. Its scope is so broad that I can see only parts of it clearly at one time, and it is exceedingly difficult to set down comprehensibly in writing…\" Jordan Peterson \n\n#### RB tree:\n\n\"We developed a new red-black tree implementation that has the same low memory overhead (two pointer fields per node), but is approximately 30% faster for insertion/removal.\"\n\nhttps://www.facebook.com/notes/facebook-engineering/scalable-memory-allocation-using-jemalloc/480222803919/\n\nhttps://github.com/jemalloc/jemalloc/blob/dev/include/jemalloc/internal/rb.h\n\n#### AVL tree:\n\nhttp://neil.brown.name/blog/AVL - after a small modification to reduce memory hits\n\n## [Just one more thing:](https://www.youtube.com/watch?v=QxBnaMGP2aY)\n\nPlease note [this function.](https://github.com/aliakseis/rb_avl_comparison/blob/c195ef96ae14f630e1add8688b269785dfd54ebf/rb_avl.cpp#L365)\n\nThis is how an item deletion from the tree is accelerated by lowering memory access.\n\n### 10000000 nodes test\n\nCPU  E2180  @ 2.00GHz\n\nTarget: x86_64-redhat-linux\ngcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)\n\nsudo nice -n -20 ./main\n\n  tree_insert time: 19.4895 seconds  \n    RB depth: 22.1559  \n  tree_search time: 17.764 seconds  \n  alternative tree_search time: 19.4725 seconds  \n  tree_remove time: 23.3087 seconds  \n\n  avl_insert time: 18.5318 seconds  \n    AVL depth: 21.7497  \n  avl_find time: 17.5718 seconds  \n  alternative avl_find time: 19.446 seconds  \n  avl_delete time: 22.9048 seconds  \n\nCPU i5-6600 @ 3.30GHz\n\nTarget: x86_64-linux-gnu\ngcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.6)\n\nsudo nice -n -20 ./main\n\n  tree_insert time: 10.375 seconds  \n    RB depth: 22.1559  \n  tree_search time: 9.85938 seconds  \n  alternative tree_search time: 10.9844 seconds  \n  tree_remove time: 12.0156 seconds  \n\n  avl_insert time: 9.89062 seconds  \n    AVL depth: 21.7497  \n  avl_find time: 7.84375 seconds  \n  alternative avl_find time: 7.67188 seconds  \n  avl_delete time: 11.5781 seconds  \n\nenum { NNODES = 20 * 10000000 };\n\nsudo nice -n -20 ./main\n\n  tree_insert time: 388.344 seconds  \n    RB depth: 26.6402  \n  tree_search time: 324.953 seconds  \n  alternative tree_search time: 330.125 seconds  \n  tree_remove time: 397.578 seconds  \n\n  avl_insert time: 298.062 seconds  \n    AVL depth: 26.0732  \n  avl_find time: 264.625 seconds  \n  alternative avl_find time: 267 seconds  \n  avl_delete time: 399.719 seconds  \n\nclang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)\n\nclang++ -Wall -O3 -std=c++11 rb_avl.cpp -o rb_avl  \nsudo nice -n -20 ./rb_avl\n\n  tree_insert time: 10.7969 seconds  \n    RB depth: 22.1559  \n  tree_search time: 10.125 seconds  \n  alternative tree_search time: 11.0312 seconds  \n  tree_remove time: 12.2969 seconds  \n\n  avl_insert time: 10.6875 seconds  \n    AVL depth: 21.7497  \n  avl_find time: 5.64062 seconds  \n  alternative avl_find time: 6.1875 seconds  \n  avl_delete time: 12.0938 seconds  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliakseis%2Frb_avl_comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliakseis%2Frb_avl_comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliakseis%2Frb_avl_comparison/lists"}