Ok, so many places online that I am looking for help represent a heap as a pyramid binary tree looking visual representation.
so for example: 45,7,20,2,6,12,10
1 2 3 4 5 6 7
|
45
/ \
7 20
/ \ / \
2 6 12 10
|
is this just a visual representation, I have not read or heard anyone mention that heaps do not use pointers like a Binary Search Tree. Only my professor mentioned it in one of his videos, but it was very quick and he did point that out again later.
I understand the concept of representing the heap in an array where each "Parent's (n)" child is 2n(Left child) and 2n + 1 (right child).
1 2 3
|
n = 1 2 3 4 5 6 7
[45][7][20][2][6][12][10]
|
so my question is when building and sorting a heap, are where just working with the "heap array" or are we using some type of "tree" such as:
1 2 3 4 5
|
struct Heap{
int data;
Heap* right;
Heap* Left;
};
|
this has me very confused.