Def g h i j kl m n o are in array36 array36 a this

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: re in Array[3..6]. Array[3..6] a This is great for a balanced tree. But if the tree is not balanced, many elements of the array are not used. 8 nodes = array of 23. 2 1 2 1 3 z 14 Left child of node i is node 2*i+1 2*i+1 Right child is node 2*i+2 Right child is node 2*i+2 x 1 y The parent of node i is node (i-1)/2 (i- Although we now do not need two child pointers to move either down or up the tree, we do need some indicator of missing nodes. Thi ca be se sto This can either be a sentinel value of the stored data, or we could have a second array indicating which nodes are occupied. So we're only just saving space. t 4 v w The parent of the last node j is (j-1)/2. (jCall this value nlast. nlast 0 r 10 9 s 19 20 22 There is, however, one data structure which uses a fully loaded binary tree and hence is optimally stored in an array. It is called a heap. heap It has one property to determine the relative positions of data: the data value at the root of a heap is larger than all of its children. 17 As a subtree is also a tree, so the subtree of...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern