All Projects → kowainik → treap

kowainik / treap

Licence: MPL-2.0 license
🍃 🌳 🍂 Efficient implementation of the implicit treap data structure

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to treap

treap
A thread-safe, persistent Treap (tree + heap) for ordered key-value mapping and priority sorting.
Stars: ✭ 23 (-64.06%)
Mutual labels:  tree, datastructure, treap
treelike
A trait to abstract over common tree functionality
Stars: ✭ 33 (-48.44%)
Mutual labels:  tree, datastructure
Slim
Surprisingly space efficient trie in Golang(11 bits/key; 100 ns/get).
Stars: ✭ 1,705 (+2564.06%)
Mutual labels:  tree, datastructure
performant-array-to-tree
Converts an array of items with ids and parent ids to a nested tree in a performant O(n) way. Runs in browsers and Node.js.
Stars: ✭ 193 (+201.56%)
Mutual labels:  tree
dataStructure
Implement different Data Structures using TypeScript and JavaScript. Deno Third-party Module.
Stars: ✭ 24 (-62.5%)
Mutual labels:  datastructure
filterCSV
Tools to manipulate CSV files in a format suitable for importing into various mindmapping programs - such as iThoughts, Freemind, and MindNode.
Stars: ✭ 29 (-54.69%)
Mutual labels:  tree
trees
No description or website provided.
Stars: ✭ 54 (-15.62%)
Mutual labels:  tree
comment tree
Render comment tree like facebook comment - reply
Stars: ✭ 37 (-42.19%)
Mutual labels:  tree
pyrubrum
An intuitive framework for creating Telegram bots.
Stars: ✭ 33 (-48.44%)
Mutual labels:  tree
rust-lapper
Rust implementation of a fast, easy, interval tree library nim-lapper
Stars: ✭ 39 (-39.06%)
Mutual labels:  tree
kirby3-bolt
Kirby 3 Plugin for a fast Page lookup even in big content trees
Stars: ✭ 24 (-62.5%)
Mutual labels:  tree
vue2-data-tree
A tree that data is lazy loaded. Support dragging node, checking node, editing node's name and selecting node.
Stars: ✭ 41 (-35.94%)
Mutual labels:  tree
ngx-tree
A derived version of angular-tree-component without mobx, better performance.
Stars: ✭ 13 (-79.69%)
Mutual labels:  tree
react-tree
Hierarchical tree component for React in Typescript
Stars: ✭ 174 (+171.88%)
Mutual labels:  tree
RangeTree
A generic interval tree implementation in C#
Stars: ✭ 144 (+125%)
Mutual labels:  tree
react-org-tree
😃 a simple organization tree component based on react
Stars: ✭ 72 (+12.5%)
Mutual labels:  tree
91-days-algorithm
91天学算法-Leetcode图解题解集合(JavaScript/C++/Python) Solutions and Explainations with Hand Drawings in Chinese(JavaScript/C++/Python)
Stars: ✭ 206 (+221.88%)
Mutual labels:  tree
5itv
familytree家谱宗谱族谱 刘三才族裔刘氏族谱网源码
Stars: ✭ 23 (-64.06%)
Mutual labels:  tree
Soft-Decision-Tree
PyTorch Implementation of "Distilling a Neural Network Into a Soft Decision Tree." Nicholas Frosst, Geoffrey Hinton., 2017.
Stars: ✭ 67 (+4.69%)
Mutual labels:  tree
jh-weapp-demo
微信小程序项目- 实现一些常用效果、封装通用组件和工具类
Stars: ✭ 60 (-6.25%)
Mutual labels:  tree

treap

Treap: tree logo Hackage Build status MPL-2.0 license

Efficient implementation of the implicit treap data structure.

What does this package provide?

This package implements a tree-like data structure called implicit treap. This data structure implements interface similar to random-access arrays, but with fast (logarithmic time complexity) insert/delete/split/merge/take/drop/rotate operations. In addition, treap allows you to specify and measure values of any monoids on a segment, like a sum of elements or minimal element on some contiguous part of the array.

When to use this package?

Use this package when you want the following operations to be fast:

  1. Access elements by index.
  2. Insert elements by index.
  3. Delete elements by index.
  4. Calculate monoidal operation (like sum, product, min, etc.) of all elements between two indices.
  5. Call slicing operations like take or drop or split.

Below you can find the table of time complexity for all operations (where n is the size of the treap):

Operation Time complexity Description
size O(1) Get number of elements in the treap
at O(log n) Access by index
insert O(log n) Insert by index
delete O(log n) Delete by index
query O(log n) Measure monoid on the segment
splitAt O(log n) Split treap by index into two treaps
merge O(log n) Merge two treaps into a single one
take O(log n) Take first i elements of the treap
drop O(log n) Drop first i elements of the treap
rotate O(log n) Put first i elements to the end

The package also comes with nice pretty-printing!

ghci> t = fromList [1..5] :: RTreap (Sum Int) Int
ghci> prettyPrint t
   5,15:2
      ╱╲
       
        
         
1,1:1   3,12:4
          ╱╲
           
            
      1,3:3 1,5:5

Alternatives

If you don't need to calculate monoidal operations, you may alternatively use Seq from the containers package as it provides more extended interface but doesn't allow to measure monoidal values on segments.

Acknowledgement

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY.

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