Coder Social home page Coder Social logo

nachinius / vanemdeboasinscala Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 2.0 78 KB

A modified van Emde Boas data structure that achieves O(lg w) predecessor and successor queries with O(n) space"

License: Apache License 2.0

Scala 100.00%
scala data-structures van-emde-boas advanced-data-structures

vanemdeboasinscala's Introduction

Build Status codecov Join the chat at https://gitter.im/nachinius/van_emde_boas_in_scala License Latest version

modified van Emde Boas Tree

the fastest successor/predecessor for integers set

A modified van Emde Boas data structure that achieves time complexity for successor/predecessor/insert/search/delete in O(lg w) (with high probability), where w is the bits of the word used to store the integer. Space complexity is O(n), where n is how many numbers are stored. Thus, the constrain is that lg n <= w, since any number must fit in a word.

If w is not too high, then this is optimal. In case w is too high, fusion trees are the best. However, dynamic versions of fusion tree only achieve expected O(lg n/lg w).

When lg w >= sqrt(lg(n)) is better to use fusion trees. However, for dinamyc fusion trees only expected O(lg n/lg w) has been achieved.

For example, in a static case, with a 32-bit word, w = 32 (as this current implementation that uses scala's Int which is 32-bit signed integer), static van Emde Boas should be used if n >~ 2^25 ~ 33 millon . Otherwise, static fusion trees should be preferred. In the same scenario, static, for 64-bit word, w = 64, this structure is better than fusion trees if n >~ 68 billon . You're likely to have memory problems with such big numbers, and you may want to switch to a distributed system. Due to its recursive nature, I imagine this structure is easy to implement in a distributed way.

The current implementation, handles scala's Int which is a signed 32-bit number. However, th

time complexity (with high probability)

  • search: O(lg w)
  • successor: O(lg w)
  • predecessor: O(lg w)
  • delete: O(lg w)
  • insert: O(lg w)

where n = 2^w is the maximum number that can be stored.

space complexity

  • O(n)
may TODO
  • Create performance tests
  • Measure memory consumption againt data size (n) and bit (w)
  • Create a complete immutable version
  • Improve usage of generators for performance tests
  • Do performance tests for Immutable Version
  • Compare performance between mutable and immutable
  • Write predecessor
  • Add delete
  • Allow any ordering
  • Augment the data structure
  • Compare to fusion tree
  • Compare to O(lg n) successor/predecessor of trees
  • Present performance results

features

  • immutable or mutable
  • dynamic
  • fully tested
  • with benchmarks code

References

  1. MIT 6.851 Advanced Data Structures, Erik Demaine lecture 11

vanemdeboasinscala's People

Contributors

gitter-badger avatar nachinius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.