Skip to content

Min head with decrease key functionality - #1202

Merged
cclauss merged 6 commits into
TheAlgorithms:masterfrom
Raj1998:master
Sep 25, 2019
Merged

Min head with decrease key functionality#1202
cclauss merged 6 commits into
TheAlgorithms:masterfrom
Raj1998:master

Conversation

@Raj1998

Copy link
Copy Markdown
Contributor

I have added MinHeap data structure with decrease key function in O(logn) time. I have also added sample usage at the bottom.

Please let me know if there are any changes.

Comment threaddata_structures/heap/min_heap.py Outdated
@cclauss

Copy link
Copy Markdown
Member

Please add at least one https://docs.python.org/3/library/doctest.html

@cclausscclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are getting there but I think one thing that we are missing in the ability to get the value given the key (name) as in print(myMinHeap("X")) # -> 1

Not much value in a heap that you can not get the data back out of ;-)

Comment threaddata_structures/heap/min_heap.py Outdated
Comment threaddata_structures/heap/min_heap.py Outdated
Comment threaddata_structures/heap/min_heap.py
Comment threaddata_structures/heap/min_heap.py
Comment threaddata_structures/heap/min_heap.py

@cclausscclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Congratulations and thanks!! 🍰

@cclauss
cclauss merged commit 6ac7b13 into TheAlgorithms:masterSep 25, 2019
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Min head with decrease key functionality
* doctest added
* __str__ changed as per Python convention
* edits in doctest
* get_value by key added
* __getitem__ added
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Raj1998@cclauss