harcourtain
harcourtain

Reputation: 13

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

Here I build the heap following two methods:

hand solution

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

Upvotes: 1

Views: 50

Answers (1)

trincot
trincot

Reputation: 351084

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

Upvotes: 0

Related Questions