Skip to main content

Heap data structure,Gives a feel like using priority queue in Java and C++.

Project description

 Heap

Heap data structure,Gives a feel like using priority queue in Java and C++. crete instance Heap(List,Key) Key can be any lambda or other function

Eg:-

do not mix datatypes other wise error may happen other wise customize the func to handle multipel datatypes

def func(x):

customize the function as you wish and return

l =[el1,el2,…….,eln]

Initialization heap = Heap(l,key = lambda x: func(x)) <- user negative return value to implement max_hap , by default min_heap

Eg:-

heap = Heap(l,key = lambda x: func(x)) <- min heap heap = Heap(l,key = lambda x: -func(x)) <- max heap

heap.show() <- it shows the entire heap

heap.size() <- returns the size of the heap(no of element it contains)

heap.push(x) <- enter an element

heap.pop() <- removes and returns the top most element

heap.peek() <- returns the top element without removing it

heap.empty() <- returns whether heap is empty or not

Installation

copy from PyPi and paste to cmd and enter

How to use it?

Import it in python script and use by creating Heap class Instance from generic_heap import Heap

License

Copyright 2021 Pritam Sarkar

This repository is licensed under the MIT license. See LICENSE for details.

Change Log

0.0.1 (18/07/2021)

  • First Release

1.0.1 (09/08/2021)

  • First Release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generic_heap-1.0.1.tar.gz (2.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page