Giter VIP home page Giter VIP logo

Naive Skip List

跳表是William Pugh于1990年提出的可替代自平衡树的数据结构[^1]。Naive Skip List是我实现的一个简单的skip list数据结构。

Usages

Initialization

Naive Skip list提供了一个默认参数的初始化方法:

Skiplist list = new Skiplist();

Insertion

向跳表中插入元素需调用add(Integer data)方法。如下面的示例:

list.add(data);

Search

Naive Skip List支持两种形式的查找操作:

  • 寻找某个特定值
  • 寻找某个区间内的值
list.search(data); // 寻找某个特定值
list.searchRange(begin, end); // 寻找某个区间内的值

Simple Benchmark

测试对比了Naive Skip List和jdk中的TreeMap,具体结果如下:

Skiplist benchmark:
--- 200000 times INSERTATION: 0.1593991sec
--- 200000 times SEARCH : 0.1267432sec
--- 200000 times ERASE : 0.1214688sec

TreeMap benchmark:
--- 200000 times INSERTATION: 0.0836352sec
--- 200000 times SEARCH : 0.0659163sec
--- 200000 times ERASE : 0.0858767sec

测试代码为Main类中的benchmark方法:

benchmark(200000);// 参数为测试的规模

[^ 1]: William Pugh (1990). Skip Lists: A Probabilistic Alternative to Balanced Trees.
[^ 2]: ticki's bolg (2016). Skiplist done right. [OL] http://ticki.github.io/blog/skip-lists-done-right

[^ 3]: somnzz (2019) 跳表这种高效的数据结构,值得每一个程序员掌握. [OL] https://zhuanlan.zhihu.com/p/54869087
[^ 4]: Dragon Energy (2015). Answer #34003558. [OL] https://stackoverflow.com/questions/31580869/skip-lists-are-they-really-performing-as-good-as-pugh-paper-claim/34003558#34003558

htrekker's Projects

ad_examples icon ad_examples

A collection of anomaly detection methods (iid/point-based, graph and time series) including active learning for anomaly detection/discovery, bayesian rule-mining, description for diversity/explanation/interpretability. Analysis of incorporating label feedback with ensemble and tree-based detectors. Includes adversarial attacks with Graph Convolutional Network.

cppguide icon cppguide

C/C++学习,后端开发进阶指南。

gantt-elastic icon gantt-elastic

Gantt Chart [ javascript gantt chart, gantt component, vue gantt, vue gantt chart, responsive gantt, project manager , vue projects ]

gogs icon gogs

Gogs is a painless self-hosted Git service

project-table icon project-table

A table design for project management. An imitation of SeaTable.

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.