Giter Site home page Giter Site logo

aliakseis / rb_avl_comparison Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 36 KB

Comparing RB and AVL tree implementations. We Need To Go Deeper.

C 77.24% C++ 22.70% Makefile 0.07%
tree rb-avl tree-insert avl-implementations tagged-pointers binary-search-tree data-structures avl avl-tree avl-tree-implementations

rb_avl_comparison's Introduction

rb_avl_comparison

Comparing RB and AVL implementations

trump_family

Make AVL Trees Great Again announcement

"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

RB tree:

"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."

https://www.facebook.com/notes/facebook-engineering/scalable-memory-allocation-using-jemalloc/480222803919/

https://github.com/jemalloc/jemalloc/blob/dev/include/jemalloc/internal/rb.h

AVL tree:

http://neil.brown.name/blog/AVL - after a small modification to reduce memory hits

Please note this function.

This is how an item deletion from the tree is accelerated by lowering memory access.

10000000 nodes test

CPU E2180 @ 2.00GHz

Target: x86_64-redhat-linux gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)

sudo nice -n -20 ./main

tree_insert time: 19.4895 seconds
RB depth: 22.1559
tree_search time: 17.764 seconds
alternative tree_search time: 19.4725 seconds
tree_remove time: 23.3087 seconds

avl_insert time: 18.5318 seconds
AVL depth: 21.7497
avl_find time: 17.5718 seconds
alternative avl_find time: 19.446 seconds
avl_delete time: 22.9048 seconds

CPU i5-6600 @ 3.30GHz

Target: x86_64-linux-gnu gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.6)

sudo nice -n -20 ./main

tree_insert time: 10.375 seconds
RB depth: 22.1559
tree_search time: 9.85938 seconds
alternative tree_search time: 10.9844 seconds
tree_remove time: 12.0156 seconds

avl_insert time: 9.89062 seconds
AVL depth: 21.7497
avl_find time: 7.84375 seconds
alternative avl_find time: 7.67188 seconds
avl_delete time: 11.5781 seconds

enum { NNODES = 20 * 10000000 };

sudo nice -n -20 ./main

tree_insert time: 388.344 seconds
RB depth: 26.6402
tree_search time: 324.953 seconds
alternative tree_search time: 330.125 seconds
tree_remove time: 397.578 seconds

avl_insert time: 298.062 seconds
AVL depth: 26.0732
avl_find time: 264.625 seconds
alternative avl_find time: 267 seconds
avl_delete time: 399.719 seconds

clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)

clang++ -Wall -O3 -std=c++11 rb_avl.cpp -o rb_avl
sudo nice -n -20 ./rb_avl

tree_insert time: 10.7969 seconds
RB depth: 22.1559
tree_search time: 10.125 seconds
alternative tree_search time: 11.0312 seconds
tree_remove time: 12.2969 seconds

avl_insert time: 10.6875 seconds
AVL depth: 21.7497
avl_find time: 5.64062 seconds
alternative avl_find time: 6.1875 seconds
avl_delete time: 12.0938 seconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.