Can I get multiple complete binary trees for a given array by different methods?

46 Views Asked by At

Here I build the heap following two methods:

hand solution

Can I get multiple complete binary trees for a given array?

  • Method 1 - Insertion;
  • Method 2 - Sub trees
1

There are 1 best solutions below

1
On BEST ANSWER

Yes, you can get different complete binary trees as heaps for the same data, depending of the method you use to build the heap.

Note that the first (insertion) method [Williams’ method] is less efficient than the second [Floyd’s method], but they both produce a correct heap, even though they are not equal. See Wikipedia: building a heap