Lecture 12: AA Trees, Treaps

Total Page:16

File Type:pdf, Size:1020Kb

Lecture 12: AA Trees, Treaps AA-Trees! The implementation and number of rotation cases in Red-Black Trees is complex! AA-trees:! •! fewer rotation cases so easier to code, especially deletions (eliminates about half of the rotation cases)! •! named after its inventor Arne Andersson (1993)," Lecture 12: AA Trees! an optimization over original definition of Binary B-trees" Treaps! (BB-trees) by Bayer (1971)! AA-trees still have O(log n) searches in the worst- case, although they are slightly less efficient empirically! Demo: http://www.cis.ksu.edu/~howell/viewer/viewer.html! [McCollam]! AA-Tree Ordering Properties! An AA-Tree Example! An AA-Tree is a binary search tree with all the 30 ordering properties of a red-black tree: ! 1.! Every node is colored either red or black! 15 70 2.! The root is black! 50 85 3.! External nodes are black! 5 20 4.! If a node is red, its children must be black! 10 35 60 80 90 5.! All paths from any node to a descendent leaf must contain the same number of black nodes 65 (black-height, not including the node itself)! 40 55 PLUS! No left red children!! 6.! Left children may not be red! Half of red-black tree rotation cases eliminated!! (Which M-way trees are AA-trees equivalent to?)! [McCollam]! [McCollam]! Representation of Balancing Info! Redefinition of “Leaf” ! The level of a node (instead of color) is used as Both the terms leaf and level are redefined:! balancing info! A leaf in an AA-tree is a node with no black •! “red” nodes are simply nodes that located at the same internal-node as children! level as their parents! For the tree on the previous slide:! 30 70 30 70 15 50 60 85 5 10 20 15 50 60 85 35 40 55 65 80 90 all leaf nodes! 5 10 20 35 40 55 65 80 90 [McCollam]! [McCollam]! Redefinition of “Level” ! Implications of Ordering Properties! The level of a node in an AA-tree is:! 1.!Horizontal links are right links! •! leaf nodes are at level 1! •! because only right children may be red! •! red nodes are at the level of their parent! •! black nodes are at one less than the level of their parent! 2.!There may not be double horizontal links! •! as in red-black trees, a black node corresponds to a level change •! because there cannot be double red nodes! in the corresponding 2-3 tree! 30 70 30 70 Level 3! 15 50 60 85 Level 2! 15 50 60 85 5 10 20 35 40 80 90 5 55 65 Level 1! 10 20 35 40 55 65 80 90 [McCollam]! [McCollam]! Implications of Ordering Properties! Implications of Ordering Properties! 3.!Nodes at level 2 or higher must have two children! 5.! Any simple path from a black node to a leaf 4.!If a node does not have a right horizontal link, its contains one black node on each level! two children are at the same level! 30 70 30 70 Level 3! Level 3! Level 2! 15 50 60 85 Level 2! 15 50 60 85 5 5 Level 1! 10 20 35 40 55 65 80 90 Level 1! 10 20 35 40 55 65 80 90 [McCollam]! [McCollam]! Example: Insert 45! Example: Insert 45! First, insert as for simple binary search tree! After insert to right of 40:! Newly inserted node is red! Problem: double right horizontal links starting at 35, need to split! 45 30 70 30 70 15 50 60 85 15 50 60 85 5 5 20 10 20 35 40 55 65 80 90 10 35 40 45 55 65 80 90 [McCollam]! [McCollam]! Split: Removing Double Reds! Example: Insert 45! Problem: With G X P G inserted, there After split at 35:! are two reds in a Problem: left horizontal link at 50 A B row! is introduced, need to skew! P Split is a simple X G left rotation 30 70 between X and P! A B P 15 40 50 60 85 P’s level increases X G 5 10 20 in the AA-tree ! 35 45 55 65 80 90 A B [McCollam]! [McCollam]! P X P G Skew: Removing Left Horizontal Link! Example: Insert 45! X G split! A B Problem: left horizontal A B P X After skew at 50:! link in AA-tree! Problem: double right horizontal links starting at , need to split! A 40 Skew is a simple right B C rotation between X and P! P X 30 70 P remains at the same A B C level as X! 15 40 50 60 85 P X 5 20 10 35 45 55 65 80 90 A B C [McCollam]! [McCollam]! P X P X P skew! X P G Example: Insert 45! Example: Insert 45! X G A B C A B C split! A B A After split at 40:! After skew at 70:! B Problem: left horizontal link at 70 introduced Problem: double right horizontal links (50 is now on same level as 70), need to skew! starting at 30, need to split! 30 50 70 30 50 70 15 40 60 85 15 40 60 85 5 20 5 20 10 35 45 55 65 80 90 10 35 45 55 65 80 90 [McCollam]! [McCollam]! Example: Insert 45! AATree::Insert()! After split at :! void AATree::! 30 insert(Link &root, Node &add) {! Insertion is complete (finally!)! if (root == NULL) // have found where to insert y! root = add;! else if (add!key < root!key) // <= if duplicate ok! 50 insert(root!left, add);! else if (add!key > root!key)! insert(root!right, add);! 30 70 // else handle duplicate if not ok! 15 40 60 85 skew(root); // do skew and split at each level! split(root);! }! 5 20 10 35 45 55 65 80 90 [McCollam]! [McCollam]! Skew: Remove Left Horizontal Link! Split: Remove Double Reds! P P X P X skew! X P G X G A B C A B C split! A B A B void AATree::skew(Link &root) { // root = X! if (root!left!level == root!level)! void AATree::split(Link &root) { // root = X! rotate_right(root);! if (root!right!right!level == root!level)! }! rotate_left(root);! }! [Lee,Andersson]! [Lee,Andersson]! AA-Tree Removal! 50 More on Skew and Split! 30 70 15 40 60 85 5 Skew may cause double reds! 10 20 35 45 55 65 80 90 Rules:! •!first we apply skew, then we do split if necessary! 1.!if node to be deleted is a red leaf, e.g., 10, remove leaf, done! After a split, the middle node increases a level, 2.!if it is parent to a single internal node, e.g., 5, it must be black; replace with its child (must be red) and recolor child black! which may create a problem for the original parent! •! parent may need to skew and split! 3.!if it has two internal-node children, swap node to be deleted with its in-order successor! •! if in-order successor is red (must be a leaf), remove leaf, done! •! if in-order successor is a single child parent, apply second rule! In both cases the resulting tree is a legit AA-tree" (we haven’t changed the number of black nodes in paths)! 3.!if in-order successor is a black leaf, or if the node to be deleted itself is a black leaf, things get complicated . .! [Lee]! Black Leaf Removal! Black Leaf Removal! p! Follow the path from the removed node to the root! 30 70 Level 3! At each node p with 2 internal-node children do:! •! if either of p’s children is two levels below p! Level 2! 15 50 60 85 •! decrease the level of p by one! 5 •! if p’s right child was a red node, decrease its level also! Level 1! 20 35 55 65 80 90 •! skew(p); skew(p!right); skew(p!right!right);! •! split(p); split(p!right);! Remove 5:" decrease 15’s level ! In the worst case, deleting one leaf node, e.g., 15, could p! 30 70 cause six nodes to all be at one level, connected by Level 3! horizontal right links! Level 2! 15 50 60 85 •! but the worst case can be" 30 70 resolved by 3 calls to" 15 20 50 85 Level 1! 35 skew(), followed by 2" 60 90 55 65 80 90 calls to split()!! [Andersson,McCollam]! [Andersson,McCollam]! Black Leaf Removal! Black Leaf Removal! skew(p!right!right)! p! decrease level ! p! 30 70 30 50 70 Level 3! Level 2! Level 2! 50 60 85 60 85 Level 1! 15 20 35 55 65 80 90 Level 1! 15 20 35 55 65 80 90 skew(p)! skew(p!right)! split(p)! p! p! 30 70 30 50 60 70 Level 2! Level 2! 50 60 85 85 Level 1! 15 20 35 55 65 80 90 Level 1! 15 20 35 55 65 80 90 [Andersson,McCollam]! [Andersson,McCollam]! Black Leaf Removal! AA-Tree p! 50 split(p!right)! Level 3! Implementation! 30 Level 2! 60 70 85 Level 1! 15 20 35 55 65 80 90 p! 50 70 Level 3! 30 Level 2! 60 85 Level 1! 15 20 35 55 65 80 90 [Andersson]! [Andersson,McCollam]! Balanced BST Summary! Randomized Search Trees! AVL Trees: maintain balance factor by rotations! Motivations:! 2-3 Trees: maintain perfect trees with variable node •!when items are inserted in order into a BST," sizes using rotations! worst-case performance becomes O(n)! •!balanced search trees either waste space or requires 2-3-4 Trees: simpler operations than 2-3 trees due complicated (empirically expensive) operations or both! to pre-splitting and pre-merging nodes, •!randomly permuting items to be inserted would ensure good wasteful in memory usage! performance of BST with high probability, but randomly permuting input is not always possible/practical, instead .
Recommended publications
  • Curriculum for Second Year of Computer Engineering (2019 Course) (With Effect from 2020-21)
    Faculty of Science and Technology Savitribai Phule Pune University Maharashtra, India Curriculum for Second Year of Computer Engineering (2019 Course) (With effect from 2020-21) www.unipune.ac.in Savitribai Phule Pune University Savitribai Phule Pune University Bachelor of Computer Engineering Program Outcomes (PO) Learners are expected to know and be able to– PO1 Engineering Apply the knowledge of mathematics, science, Engineering fundamentals, knowledge and an Engineering specialization to the solution of complex Engineering problems PO2 Problem analysis Identify, formulate, review research literature, and analyze complex Engineering problems reaching substantiated conclusions using first principles of mathematics natural sciences, and Engineering sciences PO3 Design / Development Design solutions for complex Engineering problems and design system of Solutions components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and Environmental considerations PO4 Conduct Use research-based knowledge and research methods including design of Investigations of experiments, analysis and interpretation of data, and synthesis of the Complex Problems information to provide valid conclusions. PO5 Modern Tool Usage Create, select, and apply appropriate techniques, resources, and modern Engineering and IT tools including prediction and modeling to complex Engineering activities with an understanding of the limitations PO6 The Engineer and Apply reasoning informed by
    [Show full text]
  • Through the Concept of Data Structures, the Self- Balancing Binary Search Tree
    International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 06 Issue: 01 | Jan 2019 www.irjet.net p-ISSN: 2395-0072 THROUGH THE CONCEPT OF DATA STRUCTURES, THE SELF- BALANCING BINARY SEARCH TREE Asniya Sadaf Syed Atiqur Rehman1, Avantika kishor Bakale2, Priyanka Patil3 1,2,3Department of Computer Science and Engineering, Prof Ram Meghe College of Engineering and Management, Badnera -------------------------------------------------------------------------***------------------------------------------------------------------------ ABSTRACT - In the word of computing tree is a known way of implementing balancing tree as binary hierarchical data structure which stores information tree they are originally discovered by Bayer and are naturally in the form of hierarchy style. Tree is a most nowadays extensively (diseased) in the standard powerful and advanced data structure. This paper is literature or algorithm Maintaining the invariant of red mainly focused on self -balancing binary search tree(BST) black tree through Haskell types system using the nested also known as height balanced BST. A BST is a type of data data types this give small list noticeable overhead. Many structure that adjust itself to provide the consistent level gives small list overhead can be removed by the use of of node access. This paper covers the different types of BST existential types [4]. their analysis, complexity and application. 3.1. AVL TREE Key words: AVL Tree, Splay Tree, Skip List, Red Black Tree, BST. AVL Tree is best example of self-balancing search tree; this means that AVL Tree is also binary search tree 1. INTRODUCTION which is also balancing tree. A binary tree is said to be Tree data structures are the similar like Maps and Sets, balanced if different between the height of left and right.
    [Show full text]
  • Simple Balanced Binary Search Trees
    Simple Balanced Binary Search Trees Prabhakar Ragde Cheriton School of Computer Science University of Waterloo Waterloo, Ontario, Canada [email protected] Efficient implementations of sets and maps (dictionaries) are important in computer science, and bal- anced binary search trees are the basis of the best practical implementations. Pedagogically, however, they are often quite complicated, especially with respect to deletion. I present complete code (with justification and analysis not previously available in the literature) for a purely-functional implemen- tation based on AA trees, which is the simplest treatment of the subject of which I am aware. 1 Introduction Trees are a fundamental data structure, introduced early in most computer science curricula. They are easily motivated by the need to store data that is naturally tree-structured (family trees, structured doc- uments, arithmetic expressions, and programs). We also expose students to the idea that we can impose tree structure on data that is not naturally so, in order to implement efficient manipulation algorithms. The typical first example is the binary search tree. However, they are problematic. Naive insertion and deletion are easy to present in a first course using a functional language (usually the topic is delayed to a second course if an imperative language is used), but in the worst case, this im- plementation degenerates to a list, with linear running time for all operations. The solution is to balance the tree during operations, so that a tree with n nodes has height O(logn). There are many different ways of doing this, but most are too complicated to present this early in the curriculum, so they are usually deferred to a later course on algorithms and data structures, leaving a frustrating gap.
    [Show full text]
  • Balanced Binary Search Trees – AVL Trees, 2-3 Trees, B-Trees
    Balanced binary search trees – AVL trees, 2‐3 trees, B‐trees Professor Clark F. Olson (with edits by Carol Zander) AVL trees One potential problem with an ordinary binary search tree is that it can have a height that is O(n), where n is the number of items stored in the tree. This occurs when the items are inserted in (nearly) sorted order. We can fix this problem if we can enforce that the tree remains balanced while still inserting and deleting items in O(log n) time. The first (and simplest) data structure to be discovered for which this could be achieved is the AVL tree, which is names after the two Russians who discovered them, Georgy Adelson‐Velskii and Yevgeniy Landis. It takes longer (on average) to insert and delete in an AVL tree, since the tree must remain balanced, but it is faster (on average) to retrieve. An AVL tree must have the following properties: • It is a binary search tree. • For each node in the tree, the height of the left subtree and the height of the right subtree differ by at most one (the balance property). The height of each node is stored in the node to facilitate determining whether this is the case. The height of an AVL tree is logarithmic in the number of nodes. This allows insert/delete/retrieve to all be performed in O(log n) time. Here is an example of an AVL tree: 18 3 37 2 11 25 40 1 8 13 42 6 10 15 Inserting 0 or 5 or 16 or 43 would result in an unbalanced tree.
    [Show full text]
  • A Speculation-Friendly Binary Search Tree Tyler Crain, Vincent Gramoli, Michel Raynal
    A Speculation-Friendly Binary Search Tree Tyler Crain, Vincent Gramoli, Michel Raynal To cite this version: Tyler Crain, Vincent Gramoli, Michel Raynal. A Speculation-Friendly Binary Search Tree. [Research Report] PI-1984, 2011, pp.21. inria-00618995v2 HAL Id: inria-00618995 https://hal.inria.fr/inria-00618995v2 Submitted on 5 Mar 2012 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Publications Internes de l’IRISA ISSN : 2102-6327 PI 1984 – septembre 2011 A Speculation-Friendly Binary Search Tree* Tyler Crain** , Vincent Gramoli*** Michel Raynal**** [email protected], vincent.gramoli@epfl.ch, [email protected] Abstract: We introduce the first binary search tree algorithm designed for speculative executions. Prior to this work, tree structures were mainly designed for their pessimistic (non-speculative) accesses to have a bounded complexity. Researchers tried to evaluate transactional memory using such tree structures whose prominent example is the red-black tree library developed by Oracle Labs that is part of multiple benchmark distributions. Although well-engineered, such structures remain badly suited for speculative accesses, whose step complexity might raise dramatically with contention. We show that our speculation-friendly tree outperforms the existing transaction-based version of the AVL and the red-black trees.
    [Show full text]
  • Wrapped Kd Trees Handed
    CMSC 420: Spring 2021 Programming Assignment 2: Wrapped k-d Trees Handed out: Tue, Apr 6. Due: Wed, Apr 21, 11pm. (Submission via Gradescope.) Overview: In this assignment you will implement a variant of the kd-tree data structure, called a wrapped kd-tree (or WKDTree) to store a set of points in 2-dimensional space. This data structure will support insertion, deletion, and a number of geometric queries, some of which will be used later in Part 3 of the programming assignment. The data structure will be templated with the point type, which is any class that implements the Java interface LabeledPoint2D, as described in the file LabeledPoint2D.java from the provided skeleton code. A labeled point is a 2-dimensional point (Point2D from the skeleton code) that supports an additional function getLabel(). This returns a string associated with the point. In our case, the points will be the airports from our earlier projects, and the labels will be the 3-letter airport codes. The associated point (represented as a Point2D) can be extracted using the function getPoint2D(). The individual coordinates (which are floats) can be extracted directly using the functions getX() and getY(), or get(i), where i = 0 for x and i = 1 for y. Your wrapped kd-tree will be templated with one type, which we will call LPoint (for \labeled point"). For example, your file WKDTree will contain the following public class: public class WKDTree<LPoint extends LabeledPoint2D> { ... } Wrapped kd-Tree: Recall that a kd-tree is a data structure based on a hierarchical decomposition of space, using axis-orthogonal splits.
    [Show full text]
  • Slides-Data-Structures.Pdf
    Data structures ● Organize your data to support various queries using little time an space Example: Inventory Want to support SEARCH INSERT DELETE ● Given n elements A[1..n] ● Support SEARCH(A,x) := is x in A? ● Trivial solution: scan A. Takes time Θ(n) ● Best possible given A, x. ● What if we are first given A, are allowed to preprocess it, can we then answer SEARCH queries faster? ● How would you preprocess A? ● Given n elements A[1..n] ● Support SEARCH(A,x) := is x in A? ● Preprocess step: Sort A. Takes time O(n log n), Space O(n) ● SEARCH(A[1..n],x) := /* Binary search */ If n = 1 then return YES if A[1] = x, and NO otherwise else if A[n/2] ≤ x then return SEARCH(A[n/2..n]) else return SEARCH(A[1..n/2]) ● Time T(n) = ? ● Given n elements A[1..n] ● Support SEARCH(A,x) := is x in A? ● Preprocess step: Sort A. Takes time O(n log n), Space O(n) ● SEARCH(A[1..n],x) := /* Binary search */ If n = 1 then return YES if A[1] = x, and NO otherwise else if A[n/2] ≤ x then return SEARCH(A[n/2..n]) else return SEARCH(A[1..n/2]) ● Time T(n) = O(log n). ● Given n elements A[1..n] each ≤ k, can you do faster? ● Support SEARCH(A,x) := is x in A? ● DIRECTADDRESS: Initialize S[1..k] to 0 ● Preprocess step: For (i = 1 to n) S[A[i]] = 1 ● T(n) = O(n), Space O(k) ● SEARCH(A,x) = ? ● Given n elements A[1..n] each ≤ k, can you do faster? ● Support SEARCH(A,x) := is x in A? ● DIRECTADDRESS: Initialize S[1..k] to 0 ● Preprocess step: For (i = 1 to n) S[A[i]] = 1 ● T(n) = O(n), Space O(k) ● SEARCH(A,x) = return S[x] ● T(n) = O(1) ● Dynamic problems: ● Want to support SEARCH, INSERT, DELETE ● Support SEARCH(A,x) := is x in A? ● If numbers are small, ≤ k Preprocess: Initialize S to 0.
    [Show full text]
  • CMSC 420: Lecture 6 2-3, Red-Black, and AA Trees
    CMSC 420 Dave Mount CMSC 420: Lecture 6 2-3, Red-black, and AA trees \A rose by any other name": In today's lecture, we consider three closely related search trees. All three have the property that they support find, insert, and delete in time O(log n) for a tree with n nodes. Although the definitions appear at first glance to be different, they are essentially equivalent or very slight variants of each other. These are 2-3 trees, red-black trees, and AA trees. Together, they show that the same idea can be viewed from many different perspectives. 2-3 Trees: An \ideal" binary search tree has n nodes and height roughly lg n. (More precisely, the ideal would be blg nc, where we recall our convention that \lg" means logarithm base 2.) However, it is not possible to efficiently maintain a tree subject to such rigid requirements. AVL trees relax the height restriction by allowing the two subtrees associated with each node to be of similar heights. Another way to relax the requirements is to say that a node may have either two or three children (see Fig.1(a) and (b)). When a node has three children, it stores two keys. Given the two key values b and d, the three subtrees A, C, and E must satisfy the requirement that for all a 2 A, c 2 C, and e 2 E, we have a < b < c < d < e; (The concept of an inorder traversal of such a tree can be generalized, but it involves visiting each 3-node twice, once to visit the first key and again to visit the second key.) These are called 2-nodes and 3-nodes, respectively.
    [Show full text]
  • Advanced Data Structures and Implementation
    www.getmyuni.com Advanced Data Structures and Implementation • Top-Down Splay Trees • Red-Black Trees • Top-Down Red Black Trees • Top-Down Deletion • Deterministic Skip Lists • AA-Trees • Treaps • k-d Trees • Pairing Heaps www.getmyuni.com Top-Down Splay Tree • Direct strategy requires traversal from the root down the tree, and then bottom-up traversal to implement the splaying tree. • Can implement by storing parent links, or by storing the access path on a stack. • Both methods require large amount of overhead and must handle many special cases. • Initial rotations on the initial access path uses only O(1) extra space, but retains the O(log N) amortized time bound. www.getmyuni.com www.getmyuni.com Case 1: Zig X L R L R Y X Y XR YL Yr XR YL Yr If Y should become root, then X and its right sub tree are made left children of the smallest value in R, and Y is made root of “center” tree. Y does not have to be a leaf for the Zig case to apply. www.getmyuni.com www.getmyuni.com Case 2: Zig-Zig L X R L R Z Y XR Y X Z ZL Zr YR YR XR ZL Zr The value to be splayed is in the tree rooted at Z. Rotate Y about X and attach as left child of smallest value in R www.getmyuni.com www.getmyuni.com Case 3: Zig-Zag (Simplified) L X R L R Y Y XR X YL YL Z Z XR ZL Zr ZL Zr The value to be splayed is in the tree rooted at Z.
    [Show full text]
  • Avl Tree Example Program in Data Structure
    Avl Tree Example Program In Data Structure Victualless Kermie sometimes serializes any pathographies cotise maybe. Stanfield coedit inspirationally. Sometimes hung Moss overinsures her graze temporizingly, but circumferential Ira fluorinating inopportunely or sulphurating unconditionally. Gnu general purpose, let us that tree program demonstrates operations are frequently passed by reference. AVL tree Rosetta Code. Rotation does not found to maintain the example of the above. Here evidence will get program for AVL tree in C An AVL Adelson-Velskii and Landis tree. Example avl tree data more and writes for example avl tree program in data structure while balancing easier to check that violates one key thing about binary heap. Is an AVL Tree Balanced19 top. AVL Tree ring Data Structure Top 3 Operations Performed on. Balanced Binary Search Trees AVL Trees. Example rush to show insertion into an AVL Tree. Efficient algorithm with in data structure is consumed entirely new. What is AVL tree Data structure Rotations in AVL tree All AVL operations with FULL CODE DSA AVL Tree Implementation with all. Checks if avl trees! For plant the node 12 has hung and notice children strictly less and greater than 12. The worst case height became an AVL tree with n nodes is 144 log2n 2 Thus. What clothes the applications of AVL trees ResearchGate. What makes a tree balanced? C code example AVL tree with insertion deletion and. In this module we study binary search trees which are dumb data structure for doing. To erode a node with our key Q in the binary tree the algorithm requires seven.
    [Show full text]
  • Implementation of the Tree Structure in the XML and Relational Database
    Proceedings of Informing Science & IT Education Conference (InSITE) 2012 Implementation of the Tree Structure in the XML and Relational Database Aleksandar Bulajic Nenad Filipovic Faculty of Information Faculty of Engineering Technology, Science, Metropolitan University, University of Kragujevac, Belgrade, Serbia Kragujevac, Serbia [email protected] [email protected] Abstract A tree structure is a powerful tool for storing and manipulating all kind of data, without differ- ences is it used for natural language analysis, compiling computer languages or storing and ana- lyzing scientific or business data. Algorithms for searching and browsing tree structures are well known, and for free are available numbers of tools for manipulating tree structures implemented in different computer languages. Even is impossible to avoid these algorithms and tools, primary focus in this paper is XML and XML tools. Storing and retrieving, as well as validation of XML tree structures in relational database can be a challenge. This document describes these challenges and currently available solutions. Keywords: Tree structure, XQuey, XML, XML Parser, XSLT, XML Schema, DOM, SAX, Da- tabase, SQL. Introduction Tree structure in computer science is a data structure used for representing hierarchical data struc- tures. Oxford Dictionary (Oxford Advanced Learner’s Dictionary 2011) describes hierarchy as “a system, especially in a society or an organization, in which people are organized into different levels of importance from highest to lowest” and Wikipedia describes hierarchy as “Greek: hier- archia (ἱεραρχία), from hierarches, "leader of sacred rites") is an arrangement of items (objects, names, values, categories, etc.) in which the items are represented as being "above," "below," or "at the same level as" one another.” These definitions are not sufficient because a Tree structure requires also that each node has only one parent and can have zero or more children, and is an acyclic connected graph.
    [Show full text]
  • CMSC 420 Data Structures1
    CMSC 420 Data Structures1 David M. Mount Department of Computer Science University of Maryland Fall 2019 1 Copyright, David M. Mount, 2019, Dept. of Computer Science, University of Maryland, College Park, MD, 20742. These lecture notes were prepared by David Mount for the course CMSC 420, Data Structures, at the University of Maryland. Permission to use, copy, modify, and distribute these notes for educational purposes and without fee is hereby granted, provided that this copyright notice appear in all copies. Lecture Notes 1 CMSC 420 Lecture 1: Course Introduction and Background Algorithms and Data Structures: The study of data structures and the algorithms that ma- nipulate them is among the most fundamental topics in computer science. Most of what computer systems spend their time doing is storing, accessing, and manipulating data in one form or another. Some examples from computer science include: Information Retrieval: List the 10 most informative Web pages on the subject of \how to treat high blood pressure?" Identify possible suspects of a crime based on fingerprints or DNA evidence. Find movies that a Netflix subscriber may like based on the movies that this person has already viewed. Find images on the Internet containing both kangaroos and horses. Geographic Information Systems: How many people in the USA live within 25 miles of the Mississippi River? List the 10 movie theaters that are closest to my current location. If sea levels rise 10 meters, what fraction of Florida will be under water? Compilers: You need to store a set of variable names along with their associated types. Given an assignment between two variables we need to look them up in a symbol table, determine their types, and determine whether it is possible to cast from one type to the other).
    [Show full text]