{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec0318-BSTbalance - delete traverse something new… which...

Info icon This preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
MP5 available. Due 4/1 (EC due 3/18). Today: Binary Search Trees – analysis, balance, and rotations. Announcements:
Image of page 1

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

View Full Document Right Arrow Icon
Binary Tree - the height of a Binary Tree height(T) is: • ______ if T is empty • 1 + max{height(T L ), height(T R )}, otherwise The algorithms on BST depend on the height (h) of the tree. The analysis should be in terms of the amt of data (n) the tree contains. So we need a relationship between h and n. h f(n) h g(n)
Image of page 2
Binary Tree (theory moment #2) what is minimum number of nodes (n) in a tree of height h? what is the greatest possible height (h) for a tree of n nodes?
Image of page 3

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

View Full Document Right Arrow Icon
Binary Search Tree - The height of a BST depends on the order in which the data is inserted into it. 1 3 2 4 5 7 6 vs. 4 2 3 6 7 1 5 operation avg case worst case sorted array sorted list find insert
Image of page 4
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
Image of page 9

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

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

Unformatted text preview: delete traverse something new… which tree makes you happiest? 50 70 90 50 70 90 The “height balance” of a tree T is: b = height(T L ) - height(T R ) A tree T is “height balanced” if: • • Binary Search Tree - is this tree “height balanced”? balanced trees - rotations 50 90 99 95 80 60 85 40 20 30 balanced trees - rotations 70 60 80 50 20 40 balanced trees - rotations 70 60 80 50 20 40 balanced trees - rotations summary: 1. there are 4 kinds: left, right, left-right, right-left (symmetric!) 2. local operations (subtrees not affected) 3. constant time operations 4. BST characteristic maintained height balanced trees - we have a special name: Three issues to consider as we move toward implementation: Rotating Maintaining height Detecting imbalance...
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