Giter VIP home page Giter VIP logo

fibheap's Introduction

Overview

codecov

fibheap is small and simple Fibonacci Heap implementation, written in Go.

It can be utilized as a min or max heap, depending on the implementation of the Item.Less method.

Fibonacci heaps are a type of heap data structure that provide faster insertion and deletion operations compared to binary heaps, but at the cost of increased space complexity. Depending on the concrete implementation of the binary heap, it is possible to achieve better results compared to Fibonacci heaps (ex. container/heap), because of underlying array optimizations.

Operation Time Complexity (worst case)
Insert O(1)
Find min O(1)
Delete min O(logN)
Merge O(1)

Internal Representation

The heap itself is internally represented as a doubly linked circular list of nodes. Parent nodes have references to the left-most child. Each child has a reference to their parent.

An example heap representation after adding elements [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], and removing the lowest element (0): banner

Benchmarks

goos: darwin
goarch: amd64
pkg: github.com/madz-lab/fibheap
cpu: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
BenchmarkHeap_Push1000-8           25191             48070 ns/op
BenchmarkHeap_Push10000-8           2234            521024 ns/op
BenchmarkHeap_Push100000-8           178           6716704 ns/op
BenchmarkHeap_Push1000000-8           18          60324315 ns/op
BenchmarkHeap_Pop1000-8             2694            428768 ns/op
BenchmarkHeap_Pop10000-8             189           6308310 ns/op
BenchmarkHeap_Pop100000-8              9         115665221 ns/op
BenchmarkHeap_Pop1000000-8             1        2242760745 ns/op
PASS
ok      github.com/madz-lab/fibheap     14.434s

fibheap's People

Contributors

zivkovicmilos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.