![]() |
0 follower
![]() |
The (binary) heap data structure is an object in an array that can be thought of as a nearly finished binary tree. An element of the array is represented by each node in the tree.
A.length, which (as normal) shows the number of elements in the array, and A.heap-size, which indicates how many elements from the heap are stored within array A, are the two properties of an object called an array A that represents a heap. Given the index I of a node, we can simply calculate the indices of its parent, left child, and right child because the tree's root is A[1].
I like Comments Share Download (0)