Preview

Tree Balancing

Satisfactory Essays
Open Document
Open Document
3117 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Tree Balancing
L09 Tree Balancing CX1007 Data Structures 2013/14 S2

Mark Yong

Today • Importance of balance for BSTs • Balancing operaGons in self-­‐balancing BSTs • Pseudocode + worked examples

CX1007 Data Structures 2013/14 S2

2

Recall: Why use BSTs? • BSTs are a special form of BT L • At every node, L < C ≤ R – At every node, we always know whether to conGnue searching in the leW or right subtree – If we conGnue searching in the leW subtree, all nodes in the right subtree can be ignored

H E B

A

CX1007 Data Structures 2013/14 S2

C L

F C

R

G

J I

M K

D

3

Recall: Efficient search with BSTs • Search is efficient because we traverse one external path • # operaGons is proporGonal to path length • Try to keep path length low H > D H – Ie, try to keep tree balanced

E

E > D B

A

B < D C

C < D CX1007 Data Structures 2013/14 S2

L F G

J I

M K

D 4

Recall: Efficient search with BSTs • But an imbalanced BST starts to look more like a linked list! • Path length is high A

A

E

B

B C

C E

You May Also Find These Documents Helpful

  • Good Essays

    ECET 370 Week 5 Lab 5

    • 650 Words
    • 3 Pages

    Exercise 1: Review of the Lecture Content Create a project using the ArrayList class and the Main class provided in DocSharing. The ArrayList class contains implementations of the first three search methods explained in this week's lecture: sequential, sorted, and binary search. The Main class uses these three methods. These programs test the code discussed in the lecture. Compile the project, run it, and review the code that is given carefully.…

    • 650 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 1 Test Paper

    • 381 Words
    • 2 Pages

    3. Create a binary search function that tells whether a given value exists in the tree or not.…

    • 381 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    6) Trapdoor(GP,pkS,skRi,Q): Taking GP,pkS,pkRi and a keyword queries for Q=(w1,.wm),m<=las the source of information ,it yields a trapdoor TQ, 1 for Q produced by Ri.…

    • 259 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CS 220 – Programming w/ Data Structures: You have missed one assignment and one quiz. Your instructor has extended your assignment due date to this Sunday, April 10. Your instructor has also let you to take your Quiz # 2 during his office hours during this week. Let me know if you need additional support to study for this quiz. Your grade to date in this class is 30.2/37 81.62% B.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Families of the Forest

    • 2739 Words
    • 11 Pages

    This paper will be discussing the ethnography by Allen Johnson titled Families of the forest. The ethnography describes the Matsigenka people of Shimaa that live in the Peruvian Amazon. The paper will examine the Matsigenka culture, the needs and resources of the culture, and proposed projects to meet the needs of the culture.…

    • 2739 Words
    • 11 Pages
    Better Essays
  • Good Essays

    The deciduous forest can be found all over the globe. It is found primarily in eastern North America, middle Europe, southwest Russia, Japan, and China but smaller scale deciduous forests can also be found in southeastern Australia, southern South America, and New Zealand. We will be discussing North American deciduous forests found in the Appalachian Mountains of Pennsylvania.…

    • 682 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Tree Value-Excel

    • 3332 Words
    • 14 Pages

    In order to choose the best offer, the amount of payment in each offer is discounted to present at the discount rate of 10%. This is just a basic discounting problem, using the formula…

    • 3332 Words
    • 14 Pages
    Powerful Essays
  • Good Essays

    Tree Symbolism

    • 735 Words
    • 3 Pages

    People may often ask themselves why they should learn about tree symbolism. Many people would probably say the meaning of trees does not interest them. But knowing what tree symbolism means goes beyond knowing the healing properties of a tree, its elemental correspondences, or its mythological associations. Tree symbolism is a way of classifying, identifying, and organizing the array of energetic knowledge they contain and incorporating this array in people’s daily lives. Human minds are beginning to touch this understanding: “To know something is also to join with it.” To join in an understanding of life causes association with it. When we start to understand tree symbolism, we can then further our perspective into four basic concepts: cultural/historic perspectives of trees, biological functions of trees, energetic resonance of trees, and environment of trees. The beech, birch, willow, and cedar are all used symbolically throughout history to enhance beliefs, offer concrete examples, and connect meaning.…

    • 735 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Tree and Bark

    • 488 Words
    • 2 Pages

    Inside the trunk of a tree are a number of rings. Each year of the tree's life a new ring is added so many people refer to them as the annual rings. The rings are actually made up of different parts:…

    • 488 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    trees

    • 383 Words
    • 10 Pages

    She wants to draw this triangle. She needs to know angles a, b and c.…

    • 383 Words
    • 10 Pages
    Satisfactory Essays
  • Powerful Essays

    The Apple Tree

    • 1503 Words
    • 7 Pages

    Ashurt's love for Megan was presented in several details. One of those details can be his talking with his friend- Carton. When Carton told him that Megan was "a very subtle study psychologically", he seemed to go up the wall, and at that very moment Carton was no more than an ass in his eyes. It is common knowledge that whenever one is in love, his lover must be the most beautiful and perfect in the world. No mistake can be found in that person and even if she has some shortcomings, those shortcomings can become sweet ones. Ashurt here was no exception, to him, Megan was a work of nature. "She was a wild flower. A creature it did you good…

    • 1503 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    The Pohutukawa Tree

    • 652 Words
    • 3 Pages

    In Bruce Masons “ The Pohutukawa Tree” a main theme of conflict is expressed throughout the play. He shows this through the way he presents his characters, externally by the actions they take, how they present themselves with the environment and those surrounding them and also internally with the use of there dialogue or thoughts.…

    • 652 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    apple tree

    • 1177 Words
    • 5 Pages

    John Galsworthy is an English writer of XIX-XX centuries famous for The Forsyte Saga and he won the Nobel Prize in literature in 1932. It is important to know, that he started his literary career with long short stories, and The Apple Tree, which was published in 1917, is one of the most popular by Galsworthy.…

    • 1177 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Trees

    • 516 Words
    • 3 Pages

    You cannot buy time, but you can buy custom essays. This is the most practical course of action when you're buried in a mountain of writing assignments and don't have the natural inclination to write one.…

    • 516 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Want and Tree Planting

    • 260 Words
    • 2 Pages

    This picture also taken in our tree planting, as you can see on the of the mountain yous can see the beauty of that place although we are tired getting up that’s was worth it.…

    • 260 Words
    • 2 Pages
    Satisfactory Essays