Skip to main content

An alpha version of a max-Heap that utilizes numpy memmaps so memory consumption can be reduced.

Project description

Max - Binary Heap Implementation - Alpha Version (Not Fully Optimized Yet - More Features Coming)

PYPI module that provides Max, Binary Heap, functionality. This is the alpha version, and thus, requires more optimization, a few more tests, and possibly a few more functions that will be helpful for users. This implementation utilizes the numpy.memmap so overall memory consumption can be greatly reduced. The code will be cleaned and added to in the next several weeks...

#Overview Documentation for the Max - Binary Heap Implementation:

1. Core Functions:

How to use:
from MaxHeap import FUNCTION_NAME

def createBTO(filename)

  +Creates a memmap matrix and returns a list containing the following: [memmap list, # of Levels, Largest Index, Number of Nodes]
  	       +filename = String variable describing the file name of a numpy.memmap

def createBTT(filename, numElements)

  +Has the same functionality as createBTO, only it allows users to input how many elements he/she wants...

def BreadthFS(BT, value)

  +Takes the list of memmap references and searches for a particular value given by the user.
   The return values are three components: x, y, z that make up the index...
  	       +BT = memmap list
       	   +value = The value to search for...

def getHeightTwo(value, INDEX, LEVEL, BT)

  +Takes an index value provided by the user and returns the level of the tree that the index is on.
   If the provided index is not in the range 0 - INDEX, -1 will be returned...
   	  +value = The value to return the height of. (returns -1 if the value can't be found)
   	      +INDEX = The max index value of the binary heap that is occupied by a value...
  	   +LEVEL = The number of levels the binary heap has...
	 	  +BT = memmap list

def isFull(NUMNODES, LEVEL)

  +Returns 1 if the binary heap is a full tree, or -1 if not...
  	       +NUMNODES = The number of occupied nodes in the binary heap...
       		 +LEVEL = The highest level of the current binary heap...

def ExtractMax(BT, INDEX, LEVEL)

  +Returns the extracted max value, new max INDEX value, and LEVEL value respectively in that order.
  	       +INDEX = The max index value of the binary heap that is occupied by a value...
       	      +LEVEL = The number of levels the binary heap has...

def MAXBTAdd(BT, LEVEL, INDEX, NUMNODES, value)

  +Adds a new given value to the binary heap and returns the new LEVEL, max INDEX value, and number of nodes in that order.
  	    +BT = Memmap list
    	+LEVEL = The number of levels the binary heap has...
	       +INDEX = The max INDEX value of the binary heap.
	       	      +NUMNODES = The number of nodes currently occupied within the binary heap.
		      		+value = The value to add to the binary heap.

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

MaxHeap-1.0.tar.gz (7.4 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