SlideServe
Menu
Préférences
© SlideServe · v2026

Chapter 4: Trees

tam avatar
8 diapositives · 354 Views · Sep 11, 2012

Mark Allen Weiss: Data Structures and Algorithm Analysis in Java. Chapter 4: Trees. AVL Trees. Lydia Sinapova, Simpson College. AVL Trees. Keep the tree balanced Use node rotation Balanced condition: The left and the right subtrees of each node should differ by at most one level.

Chapter 4: Trees - slide 1
01 / 8Chapter 4: Trees
1 / 17

Télécharger la présentation

Chapter 4: Trees
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Chapter 4: Trees AVL Trees Lydia Sinapova, Simpson College

  2. AVL Trees • Keep the tree balanced • Use node rotation • Balanced condition: The left and the right subtrees of each node should differ by at most one level. The method was proposed by two Russian scientists Adelson-Velskii and Landis in 1962

  3. 5 3 7 6 8 9 Single Rotation The sub-tree containing the inserted node (rooted at 8) is at the same side as the ‘heavier’ sub-tree of node 5 (rooted at 7) New node Links to be changed

  4. 7 5 8 3 6 9 After the Rotation The middle node 6 is switched to the other subtree

  5. 5 5 8 7 8 7 7 8 9 6 8 7 9 6 Double Rotation New node The new node 6 is in theleft subtree of node 8, while node 8 is therightsubtree of 5 -> rotate 7 and 8 to obtain same-side trees. Animation

  6. Splay Trees Move to the top each accessed node with rotations, decreasing the depth of the tree.

  7. E I R S A C G H N Multi-Way Search Nodes contain more than one key nodes are used only to contain the keys, the actual records are stored at the terminal nodes at the bottom of the tree

  8. Complexity Issues • AVL trees: Search,Insertion, and Deletion:O(logN) Creating the tree – O(N) • Trees withmultiple keys: O(LogmN) m – branching factor