Created
August 30, 2020 09:25
-
-
Save tiwarinaman/306b01d18a782d71b907a509ac99daee to your computer and use it in GitHub Desktop.
Max Heap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data = [0,85,75,60,30,35,45] | |
| def maxHeapInsert(item): | |
| pos = len(data) | |
| data.insert(pos,item) | |
| print('After inserting the element in the heap') | |
| print(data) | |
| if pos!=0: | |
| while data[int(pos/2) <= item and int(pos/2) >=1]: | |
| data[pos] = data[int(pos/2)] | |
| data[int(pos/2)] = item | |
| print(data) | |
| pos = int(pos/2) | |
| print('Heap format in array ') | |
| print(data) | |
| maxHeapInsert(92) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment