Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Note: This is related to Java .... (Please help me with all ) If you have an arr

ID: 3686483 • Letter: N

Question

Note: This is related to Java .... (Please help me with all )

If you have an array that is used to store nodes from a binary tree, answer the following questions: Give the location of the parent of an element stored in location 55. Say whether (at location 55) is a left child or right child. If it was a full binary tree, how many cells would the array have if the height of the tree is 6? If was a complete binary tree, what would be the minimum number of cells required for the same height as in part c above?

Explanation / Answer

14..

binary tree...in array representation...

root = 0 ...first element of the array...

to access childrens... of the ith parent...

left child = 2*i+1             //where i is index of the array...

right child = 2*i+2

to access parents...

parent = (i-1)/2

a)

location =55

the parent location = (location-1)/2=(55-1)/2=54/2=27

b)

parent of location 55 is 27

means it is left child of 27...

because 2*27+1 = 55 is left child

c)

for a full binary tree the number of nodes at height h is:---2^h

for height 6:- 2^6 = 64 cells..

d)

for a complete binary tree with height 6... we must have minimum of 2 cells are required... and they must be the childs of the same parent...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote