excessdl Posted December 5, 2002 Share Posted December 5, 2002 given any 8 integers of your choosing, but they have to retain the same order, can a height-balanced tree and a heap have the same structure after all the insertions? Link to comment Share on other sites More sharing options...
0 mackol Posted December 6, 2002 Share Posted December 6, 2002 highly unlikely to because in a heap after insertion, the elements are reheaped up. furthermore, in a heap they are inserted at the next available spot. whereas in a BST they are added to the left or right and keep moving down. so back to heap, in heap we add at the bottom and move it up as per required. :) Link to comment Share on other sites More sharing options...
0 kyo116 Posted December 6, 2002 Share Posted December 6, 2002 i don't think so, but i've nvr tried. Link to comment Share on other sites More sharing options...
0 mackol Posted December 6, 2002 Share Posted December 6, 2002 re: it being possible.. i have never found a set of 8 integers which when inserted form the same tree maybe if u insert 8 integers of the same value it might form the same tree... but then it really wouldnt be a bst Link to comment Share on other sites More sharing options...
Question
excessdl
given any 8 integers of your choosing, but they have to retain the same order, can a height-balanced tree and a heap have the same structure after all the insertions?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts