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 details)

Uploaded Source

File details

Details for the file generic_heap-1.0.1.tar.gz.

File metadata

  • Download URL: generic_heap-1.0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for generic_heap-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c442029919e50aeedbdce7855c40abce7b3d82992a3275d560ad51b6e4e1da16
MD5 c3b70b35295ad45fece946626a5f9bda
BLAKE2b-256 d0b4c888d1d7f68921672bf9cb9123059ca125ea452e5cb5e34955ebe94f2bc9

See more details on using hashes here.

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