Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/madz-lab/fibheap

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/madz-lab/fibheap

  • v0.0.0-20230301213339-b41cda151075
  • Source
  • Go
  • Socket score

Version published
Created
Source

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.

OperationTime Complexity (worst case)
InsertO(1)
Find minO(1)
Delete minO(logN)
MergeO(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      	   27565	     43614 ns/op
BenchmarkHeap_Push10000-8     	    2434	    486338 ns/op
BenchmarkHeap_Push100000-8    	     196	   6143537 ns/op
BenchmarkHeap_Push1000000-8   	      20	  53343451 ns/op
BenchmarkHeap_Pop1000-8       	    1279	    930076 ns/op
BenchmarkHeap_Pop10000-8      	      84	  14635011 ns/op
BenchmarkHeap_Pop100000-8     	       5	 251245856 ns/op
BenchmarkHeap_Pop1000000-8    	       1	4416738056 ns/op
PASS
ok  	github.com/madz-lab/fibheap	17.905s

FAQs

Package last updated on 01 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc