All Projects → MauriceGit → Skiplist

MauriceGit / Skiplist

Licence: mit
A Go library for an efficient implementation of a skip list: https://godoc.org/github.com/MauriceGit/skiplist

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Skiplist

Hackerrank
📗 Solutions of more than 380 problems of Hackerrank accross several domains.
Stars: ✭ 128 (-8.57%)
Mutual labels:  data-structures
Eclipse Collections
Eclipse Collections is a collections framework for Java with optimized data structures and a rich, functional and fluent API.
Stars: ✭ 1,828 (+1205.71%)
Mutual labels:  data-structures
Leetcode Patterns
A curated list of leetcode questions grouped by their common patterns
Stars: ✭ 3,750 (+2578.57%)
Mutual labels:  data-structures
Array Hash
C++ implementation of a fast and memory efficient hash map and hash set specialized for strings
Stars: ✭ 130 (-7.14%)
Mutual labels:  data-structures
Binarytree
Python Library for Studying Binary Trees
Stars: ✭ 1,694 (+1110%)
Mutual labels:  data-structures
Datastructures Algorithms
The best library for implementation of all Data Structures and Algorithms - Trees + Graph Algorithms too!
Stars: ✭ 2,105 (+1403.57%)
Mutual labels:  data-structures
Leetcode
✏️ 算法相关知识储备 LeetCode with Python and JavaScript 📚
Stars: ✭ 1,713 (+1123.57%)
Mutual labels:  data-structures
Data Structures
Common data structures and algorithms implemented in JavaScript
Stars: ✭ 139 (-0.71%)
Mutual labels:  data-structures
Data structure and algorithms library
A collection of classical algorithms and data-structures implementation in C++ for coding interview and competitive programming
Stars: ✭ 133 (-5%)
Mutual labels:  data-structures
Placement Preparation
Hello everyone, I have created this repository specifically for competitive questions and for placements preparation.
Stars: ✭ 137 (-2.14%)
Mutual labels:  data-structures
Leetcode
😖 😕 😃LeetCode问题解题思路。
Stars: ✭ 130 (-7.14%)
Mutual labels:  data-structures
Notes
Including JVM, Java concurrency, Spring framework, Data structure and Algorithm, Computer network, Design pattern, Python, C++, Linux, Mysql, Redis,MATLAB, Git and other tools, etc.
Stars: ✭ 131 (-6.43%)
Mutual labels:  data-structures
Important Java Concepts
🚀 Complete Java - A to Z ║ 📚 Notes and Programs of all Important Concepts of Java - OOPS, Data Structures, Algorithms, Design Patterns & Development + Kotlin + Android 🔥
Stars: ✭ 135 (-3.57%)
Mutual labels:  data-structures
Merkle Tree
Merkle Trees and Merkle Inclusion Proofs
Stars: ✭ 130 (-7.14%)
Mutual labels:  data-structures
Scilab
Free and Open Source software for numerical computation providing a powerful computing environment for engineering and scientific applications.
Stars: ✭ 138 (-1.43%)
Mutual labels:  data-structures
Numcpp
C++ implementation of the Python Numpy library
Stars: ✭ 2,031 (+1350.71%)
Mutual labels:  data-structures
Dash
DASH, the C++ Template Library for Distributed Data Structures with Support for Hierarchical Locality for HPC and Data-Driven Science
Stars: ✭ 134 (-4.29%)
Mutual labels:  data-structures
19 udacity dsa
Data Structures & Algorithms Nanodegree Program from Udacity
Stars: ✭ 140 (+0%)
Mutual labels:  data-structures
You Dont Know X
🙈 curated list of inspiring resources which show you don't know that much about something you thought you knew.
Stars: ✭ 139 (-0.71%)
Mutual labels:  data-structures
Dsa Geeksclasses
DSA-Self Paced With Doubt Assistance Course Solutions in Python (Python 3)
Stars: ✭ 137 (-2.14%)
Mutual labels:  data-structures

Go Report Card cover.run

Fast Skiplist Implementation

This Go-library implements a very fast and efficient Skiplist that can be used as direct substitute for a balanced tree or linked list. All basic operations ( Find, Insert and Delete) have approximate runtimes of O(log(n)) that prove real in benchmarks.

For detailed API documentation, see the official docs: godoc.org/github.com/MauriceGit/skiplist.

This implementation introduces a minimum amount of overhead and is tailored for maximum performance across all operations. In benchmarks, this skiplist is currently the fastest implementation in Go known to me. See a thorough benchmark of multiple skiplist implementations at: github.com/MauriceGit/skiplist-survey.

Find, Insert, Delete at both ends of the SkipList

Y-Axis is measured in nanoseconds per operation for all charts

Find, Insert, Delete All functions, be it Find, Insert or Delete that operate on first or last elements in the skiplist behave in near Constant time, no matter how many elements are already inserted in the skiplist.

Random insert, random delete For real-world cases where elements are inserted or removed at random positions in the skiplist, we can clearly see the approximate O(log(n)) behaviour of the implementation which approximates to a constant value around 1800ns for Delete and 2200ns for Insert.

Comparison to other Skiplist implementations

The following graphs are taken from github.com/MauriceGit/skiplist-survey. Please visit this skiplist survey for a much more detailed comparison over several benchmarks between different skiplist implementations.

Overall, this implementation is the fastest skiplist for nearly all operations. Especially for real-world applications.

Random insert If we compare random insertions of this skiplist to other implementations, it is clearly the fastest by up to 800ns per insertion for up to 3m elements.

Random delete If we compare random deletions of this skiplist to other implementations, it is clearly the fastest by up to 300ns per deletion for up to 3m elements.

Usage


import (
    "github.com/MauriceGit/skiplist"
    "fmt"
)

type Element int
// Implement the interface used in skiplist
func (e Element) ExtractKey() float64 {
    return float64(e)
}
func (e Element) String() string {
    return fmt.Sprintf("%03d", e)
}

func main() {
    list := New()

    // Insert some elements
    for i := 0; i < 100; i++ {
        list.Insert(Element(i))
    }

    // Find an element
    if e, ok := list.Find(Element(53)); ok {
        fmt.Println(e)
    }

    // Delete all elements
    for i := 0; i < 100; i++ {
        list.Delete(Element(i))
    }
}

Convenience functions

Other than the classic Find, Insert and Delete, some more convenience functions are implemented that makes this skiplist implementation very easy and straight forward to use in real applications. All complexity values are approximates, as skiplist can only approximate runtime complexity.

Function Complexity Description
Find O(log(n)) Finds an element in the skiplist
FindGreaterOrEqual O(log(n)) Finds the first element that is greater or equal the given value in the skiplist
Insert O(log(n)) Inserts an element into the skiplist
Delete O(log(n)) Deletes an element from the skiplist
GetSmallestNode O(1) Returns the smallest element in the skiplist
GetLargestNode O(1) Returns the largest element in the skiplist
Prev O(1) Given a skiplist-node, it returns the previous element (Wraps around and allows to linearly iterate the skiplist)
Next O(1) Given a skiplist-node, it returns the next element (Wraps around and allows to linearly iterate the skiplist)
ChangeValue O(1) Given a skiplist-node, the actual value can be changed, as long as the key stays the same (Example: Change a structs data)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].