heap implementation example
Example 1: heap
A heap is a tree-based data structure in which all the nodes of the tree are in a specific order. For example, if is the parent node of , then the value of follows a specific order with respect to the value of and the same order will be followed across the tree.
Example 2: parent of heap node
let k = index you are looking at
parent = (k - 1) // 2 # floor division
leftChild = 2 * k + 1
rightChild = 2 * k + 2