14-1. AVLTrees_outside

Nh 2nh 2 nh 4nh 4 nh 8nn 6 by induction nh 2 i nh 2i

Info icon This preview shows pages 3–7. Sign up to view the full content.

View Full Document Right Arrow Icon
n(h) > 2n(h-2), n(h) > 4n(h-4), n(h) > 8n(n-6), … (by induction), n(h) > 2 i n(h-2i) Solving the base case we get: n(h) > 2  h/2-1 Taking logarithms: h < 2log n(h) +2 Thus the height of an AVL tree is O(log n) 3 4 n(1) n(2)
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
©  2004 Goodrich, Tamassia AVL Trees 4 Insertion Insertion is as in a binary search tree Always done by expanding an external node. Example: 44 17 78 32 50 88 48 62 54 w b=x a=y c=z 44 17 78 32 50 88 48 62 before insertion after insertion
Image of page 4
©  2004 Goodrich, Tamassia AVL Trees 5 Trinode Restructuring let ( a , b , c ) be an inorder listing of  x y z perform the rotations needed to make  b  the topmost node of the  three b=y a=z c=x T 0 T 1 T 2 T 3 b=y a=z c=x T 0 T 1 T 2 T 3 c=y b=x a=z T 0 T 1 T 2 T 3 b=x c=y a=z T 0 T 1 T 2 T 3 case 1: single rotation (a left rotation about a ) case 2: double rotation (a right rotation about c , then a left rotation about a ) (other two cases are symmetrical)
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
©  2004 Goodrich, Tamassia AVL Trees 6 Insertion Example, continued 88 44 17 78 32 50 48 62 2 5 1 1 3 4 2 1 54 1 T 0 T 2 T 3 x y z 2 3 4
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the 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