dango-ct Documentation
|
|
- Elfrieda Allen
- 5 years ago
- Views:
Transcription
1 dango-ct Documentation Release 0.1 Wolfgang Doll Sep 27, 2017
2
3 Contents 1 Implementation Details 3 2 Some Research 7 3 Test Data Sources 9 4 Requirements 11 5 SQL Snippets 13 6 Queries for Digraph-shaped Hierarchies 15 7 Indices and tables 19 i
4 ii
5 Contents: Contents 1
6 2 Contents
7 CHAPTER 1 Implementation Details Note: The book Pro Django from Marty Alchin is a great source of knowledge. I took a lot of ideas from it. For me realizing an application like django-ct is not possible without the knowledge out of this book. This section provides an overview of the features that will be available when the application is completed, so we can start seeing these features fall into place as the code progresses. First the act of assigning a manager to the model that need the possibilities of a closure table. This should be as simple as possible, preferably just a single attribute assignment. Simply pick a name and assign an object, just like Django s own model fields. from django.db import models from ct import models as ct class Topic(models.Model): name = models.textfield() index = ct.closuretable() def unicode (self): return u'(%s) %s' % (self.id, self.name) That s enough to get everything configured. From there, the framework is able to set up a model behind the scenes to store the closure table entries and the index attribute can be used to access those information using the API methods of django-ct. The whole registration of the manager begins by assigning a ClosureTable object to a model, so that s a good place to start defining code. There are a number of things that have to happen in sequence to get the closure table system initialized for a particular model; at a high level ClosureTable manages the following tasks: Create a model for the requested closure table in a way that the foreign keys from this table referencing the related objects in the original model (create_model()). Register signal handlers to execute when the original model is saved. These in turn add new rows to the closure table each time a new instance of the model is saved. 3
8 Assign a descriptor to the original model, using the attribute name where the ClosureTable was assigned. This descriptor will forward the work to a InstanceManager object or a ClassManager object. Before any of those steps can really begin, there s a small amount of housekeeping that must be done. Since the ClosureTable object gets assigned as an attribute of a model, the first chance it gets to execute is in the contribute_to_class() method. def contribute_to_class(self, cls, name): self.name = name models.signals.class_prepared.connect(self.finalize, sender=cls) So far is s not much, but this is the only point in the process where Django tells ClosureTable what name it was given when assigned to the model. This is stored away for future reference. The method contribute_to_class() gets called on each field in turn, in the order they appear in the namespace dictionary Python created for the model s definition. Since standard dictionaries don t have a guaranteed order, there s no way to predict how many fields will already have been processed by the time ClosureTable gets a chance to peek at the model. To solve this, we turn to a signal: class_prepared. Django fires this signal once all the fields and managers have been added to the model and everything is in place to be used by external code. That s when ClosureTable will have guaranteed access to the model so contribute_to_class() continuous by setting up a listener for class_prepared. Django will now call ClosureTable.finalize() with the fully-prepared model once everything is in place to continue processing it. That method is the responsible for performing all of the remaining tasks. Most of the details are delegated to other methods, but finalize() coordinates them. def finalize(self, sender, **kwargs): self.ctmodel = self.create_model(sender) # The ClosureTable object will be discarded, # so the signal handler can't use weak references. models.signals.post_save.connect(self.post_save, sender=sender, weak=false) descriptor = self.descriptor(self.ctmodel) setattr(sender, self.name, descriptor) There are a few different sub-steps required in creating a closure table. Adding all the logic in one method would hamper readability and maintainability, so it s been broken up into three additional methods (create_model(), get_fields() and get_options()). def create_model(self, model): attrs = {' module ': model. module } class Meta: pass Meta. dict.update(attrs) Meta. dict.update(self.get_options(model)) attrs['meta'] = Meta attrs.update(self.get_fields(model)) name = '%s_ct_%s' % (model._meta.object_name, self.name.lower()) return type(name, (models.model,), attrs) Django is Python! So we use here all the hard core Python stuff to create a new Django model class. The create_model() method above mimic the process of creating a model like in this code: from django.db import models from tests.models import Topic class Topic_ct_index(models.Model): 4 Chapter 1. Implementation Details
9 ancestor = models.foreignkey(topic, related_name='+', on_delete=models.cascade, blank=false, null=false) descendant = models.foreignkey(topic, related_name='+', on_delete=models.cascade, blank=false, null=false), path_length = models.positiveintegerfield(default=0, blank=false, null=false) class Meta: unique_together = ('ancestor', 'descendant') On this way we implement a model inside the database that looks like the original proposal from Bill Karwin: ct(c) CREATE TABLE ct ( ancestor INTEGER NOT NULL REFERENCES c (id) ON DELETE CASCADE, descendant INTEGER NOT NULL REFERENCES c (id) ON DELETE CASCADE, length INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (ancestor, descendant) ) The last two lines of the methode finalize() assignes a so called descriptor to the original model. This results in an for example index attribute in the model Topic. This attribute is implemented as a Descriptor object. class Descriptor(object): def init (self, ctmodel): self._ctmodel = ctmodel def get (self, instance, owner): if instance is None: return ClassManager(self._ctModel) return InstanceManager(self._ctModel, instance) With this django-ct can provide two different kind of API s. If we use the index like a class property the API will be provided by a ClassManager. If we use the index attribute like a instance property the API will be provided by a InstanceManager. $ python manage.py shell >>> from tests.models import Topic >>> type(topic.index) <class 'ct.manager.classmanager'> >>> a = Topic.objects.get(pk=1) >>> type(a.index) <class 'ct.manager.instancemanager'> >>> exit() 5
10 6 Chapter 1. Implementation Details
11 CHAPTER 2 Some Research Trees and Other Hierarchies in MySQL Managing hierarchies in SQL What is the most efficient/elegant way to parse a flat table into a tree? The simplest(?) way to do tree-based queries in SQL Rendering Trees with Closure Tables The Term TCT (transitive closure tables) Hierarchical Data: Persistence via Closure Table The Slides of Bill Karwin A gist with a PHP implementation. Optimize Hierarchy Queries with a Transitive Closure Table Hierarchy Queries - Creating a Transitive Closure to Optimize Rollups (Steven F. Lott) Moving Subtrees in Closure Table Hierarchies Bill Karwin: SQL Antipatterns: Avoiding the Pitfalls of Database Programming Robert Sedgewick, Kevin Wayne: Directed Graphs and some Slides 7
12 8 Chapter 2. Some Research
13 CHAPTER 3 Test Data Sources Integrated Taxonomic Information System (ITIS) 9
14 10 Chapter 3. Test Data Sources
15 CHAPTER 4 Requirements Every class C is associated with one ore more closure table classes C.CTn There is a possibility to manage more then one tree T inside of one closure table C.CTn. Every new instance I of C will be automatically added to its associated closure tables C.CTn (Building a tree T with one node. The root node) An instance I of C always has at least one reference in its closure table C.CTn. When a instance I of C is deleted, all references to I in C.CTn are be deleted too. (The tree structure is preserved) We need a ability to connect a tree T with a subtree ST. We need a ability to disconnect a subtree ST from its tree T. (This generates a new tree) 11
16 12 Chapter 4. Requirements
17 CHAPTER 5 SQL Snippets A closure table is a way of storing hierarchies (Digraph s). It involves storing all path through the graph, not just those with a direct parent-child realtionship 1. ct(c) CREATE TABLE ct ( ancestor INTEGER NOT NULL REFERENCES c (id) ON DELETE CASCADE, descendant INTEGER NOT NULL REFERENCES c (id) ON DELETE CASCADE, length INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (ancestor, descendant) ) To create a new node, we first insert the self referencing row 2. create(t) INSERT INTO ct (ancestor, descendant) VALUES (t,t) We need to insert all the nodes of the new subtree st. We use a cartesian join between the ancestors of st (going up) and the descendants of t (going down) 3. connect(t, st) INSERT INTO ct (ancestor, descendant, length) SELECT supertree.ancestor, subtree.descendant, supertree.length+subtree.length+1 AS supertree JOIN ct AS subtree WHERE subtree.ancestor = t AND supertree.descendant = st But it is not possible to connect every tree with any other subtree. The definition of our ct do not allow duplicate edges. Therefore the intersection of already existing edges and new edges must be empty. 1 Bill Karwin: SQL Antipatterns: Avoiding the Pitfalls of Database Programming - Page 36 2 Bill Karwin: SQL Antipatterns: Avoiding the Pitfalls of Database Programming - Page 38 3 Bill Karwin: Moving Subtrees in Closure Table Hierarchies 13
18 checka(t, st) SELECT ancestor, descendant INTERSECT SELECT supertree.ancestor, subtree.descendant AS supertree JOIN ct AS subtree WHERE subtree.ancestor = t AND supertree.descendant = st We disconnecting the subtree from all notes which are not descendants of st 3. disconnect(st) DELETE WHERE descendant IN (SELECT descendant WHERE ancestor = st) AND ancestor NOT IN (SELECT descendant WHERE ancestor = st) A subtree is considered disconnected if the following query returns no result. The parameter t in connect should be checked against this query. checkb(st) SELECT ancestor, descendant WHERE descendant IN (SELECT descendant WHERE ancestor = st) AND ancestor NOT IN (SELECT descendant WHERE ancestor = st) Assumption The application of the checks A and B resulting in digraphs, with special properties. Such a digraph has exactly one starting point. Each additional node has exactly one predecessor. There is no way for cycles. With this, the conditions for a data structure named tree is given. Many thanks to Bill Karwin for these beautiful how to implements a closure table ideas. 14 Chapter 5. SQL Snippets
19 CHAPTER 6 Queries for Digraph-shaped Hierarchies To retrieve the ancestors of a node st, we have to match rows in ct where the descendant is st. However the node st is still part of the result. To solve this we filter out the self referencing row of the node st. ancestors(st) SELECT ancestor WHERE descendant = st AND ancestor <> descendant To retrieve the descendants of a node st, we have to match rows in ct where the ancestor is st. The same tale as before: the node st is still part of the result if we not filtering out the self referencing row of the node st descendants(st) SELECT descendant WHERE ancestor = st AND length ancestor <> descendant Queries for direct predecessor or successor nodes should also use the length attribute in ct. We know the path length of a immediate successor is 1. The searching for the direct successors of st is now straightforward: successors(st) SELECT descendant AS successor WHERE ancestor = st AND length = 1 Adjusted accordingly we can use the same method to find the predecessors of the node st : predecessors(st) SELECT ancestor AS predecessor WHERE descendant = st AND length = 1 15
20 Childs having the same parents, are usually known as siblings. In our graph, we call this kind of relationship corporation. We can search the members of an corporation with a nested query. First we search the predecessors and second we try then to find the related successors. corporation(st) SELECT DISTINCT descendant AS member WHERE length = 1 AND ancestor IN ( SELECT ancestor WHERE descendant = st and length = 1 ) With the following query, we are able to retrieve those starting points, which lead us along the graph to the node st. startpoints(st) SELECT ancestor AS startpoint WHERE descendant = st AND ancestor NOT IN ( SELECT descendant WHERE length ancestor <> descendant ) With the following query, we are able to retrieve the end points, where the graph arrives after starting the traverse from the node st. endpoints(st) SELECT descendant AS endpoint WHERE ancestor = st AND descendant NOT IN ( SELECT ancestor WHERE length ancestor <> descendant ) A node is called a producer if he is an ancestor of another node producer() SELECT DISTINCT ancestor AS producer WHERE length ancestor <> descendant A node is called a consumer if he is an descendant of another node consumer() SELECT DISTINCT descendant AS consumer WHERE length ancestor <> descendant A node which is a consumer but not a producer is called a sink. 16 Chapter 6. Queries for Digraph-shaped Hierarchies
21 sinks() SELECT DISTINCT descendant AS sink WHERE ancestor NOT IN ( SELECT ancestor WHERE length ancestor <> descendant ) A node which is a producer but not a consumer is called a source. sources() SELECT DISTINCT ancestor AS source WHERE ancestor NOT IN ( SELECT descendant WHERE length ancestor <> descendant ) The number of head endpoints adjacent to a node is called the indegree of the node. indegree(st) SELECT COUNT(ancestor) AS indegree WHERE descendant = st and length = 1 The number of tail endpoints adjacent to a node is called its outdegree. outdegree(st) SELECT COUNT(descendant) AS outdegree WHERE ancestor = st and length = 1 Every node in ct is defined over its self referencing row. nodes() SELECT ancestor AS node WHERE ancestor = descendant We can retrieve a list of direct connections between the nodes. args() SELECT ancestor AS tail, descendant AS head WHERE length = 1 17
22 18 Chapter 6. Queries for Digraph-shaped Hierarchies
23 CHAPTER 7 Indices and tables genindex modindex search 19
Trees. Truong Tuan Anh CSE-HCMUT
Trees Truong Tuan Anh CSE-HCMUT Outline Basic concepts Trees Trees A tree consists of a finite set of elements, called nodes, and a finite set of directed lines, called branches, that connect the nodes
More informationSQLAlchemy-ORM-tree Documentation
SQLAlchemy-ORM-tree Documentation Release 0.2.0 RokuSigma Inc. and contributors July 05, 2016 Contents 1 Installation 3 2 API 5 2.1 Managers................................................. 5 2.2 ORM
More informationSlides for Faculty Oxford University Press All rights reserved.
Oxford University Press 2013 Slides for Faculty Assistance Preliminaries Author: Vivek Kulkarni vivek_kulkarni@yahoo.com Outline Following topics are covered in the slides: Basic concepts, namely, symbols,
More informationHierarchical Data in RDBMS
Hierarchical Data in RDBMS Introduction There are times when we need to store "tree" or "hierarchical" data for various modelling problems: Categories, sub-categories and sub-sub-categories in a manufacturing
More informationBinary Trees
Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what
More informationComputer Science 210 Data Structures Siena College Fall Topic Notes: Trees
Computer Science 0 Data Structures Siena College Fall 08 Topic Notes: Trees We ve spent a lot of time looking at a variety of structures where there is a natural linear ordering of the elements in arrays,
More information8) A top-to-bottom relationship among the items in a database is established by a
MULTIPLE CHOICE QUESTIONS IN DBMS (unit-1 to unit-4) 1) ER model is used in phase a) conceptual database b) schema refinement c) physical refinement d) applications and security 2) The ER model is relevant
More informationCS 231 Data Structures and Algorithms Fall Recursion and Binary Trees Lecture 21 October 24, Prof. Zadia Codabux
CS 231 Data Structures and Algorithms Fall 2018 Recursion and Binary Trees Lecture 21 October 24, 2018 Prof. Zadia Codabux 1 Agenda ArrayQueue.java Recursion Binary Tree Terminologies Traversal 2 Administrative
More informationHierarchies. QlikView Technical Brief. 26 Nov 2013, HIC
Hierarchies QlikView Technical Brief 26 Nov 2013, HIC www.qlikview.com Contents Contents... 2 Introduction... 3 Examples in real life... 3 Different types of hierarchies... 4 Balanced or Unbalanced?...
More informationdjango-audit-log Documentation
django-audit-log Documentation Release 0.8.0 Vasil Vangelovski (Atomidata) Jul 21, 2017 Contents 1 Installation 3 2 Tracking Users that Created/Modified a Model 5 2.1 Tracking Who Created a Model.....................................
More informationTrees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology
Trees : Part Section. () (2) Preorder, Postorder and Levelorder Traversals Definition: A tree is a connected graph with no cycles Consequences: Between any two vertices, there is exactly one unique path
More informationObjective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113)
Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113) 1. The number of interchanges required to sort 5, 1, 6, 2 4 in ascending order using Bubble Sort (A)
More informationGraphene Documentation
Graphene Documentation Release 1.0.dev Syrus Akbary Nov 09, 2017 Contents 1 Introduction tutorial - Graphene and Django 3 1.1 Set up the Django project........................................ 3 1.2 Hello
More informationPractical object-oriented models in SQL. Bill Karwin July 22, OSCON
Practical object-oriented models in SQL Bill Karwin July 22, 2009 - OSCON Object-Oriented vs. Relational Impedance mismatch OO operates on instances; RDBMS operates on sets Compromise either OO strengths
More information11 TREES DATA STRUCTURES AND ALGORITHMS IMPLEMENTATION & APPLICATIONS IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD
DATA STRUCTURES AND ALGORITHMS 11 TREES IMPLEMENTATION & APPLICATIONS IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD WWW.IMRANIHSAN.COM LECTURES ADAPTED FROM: DANIEL KANE, NEIL RHODES DEPARTMENT
More informationCSE 214 Computer Science II Introduction to Tree
CSE 214 Computer Science II Introduction to Tree Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse214/sec02/ Tree Tree is a non-linear
More informationPASSWORDS TREES AND HIERARCHIES. CS121: Relational Databases Fall 2017 Lecture 24
PASSWORDS TREES AND HIERARCHIES CS121: Relational Databases Fall 2017 Lecture 24 Account Password Management 2 Mentioned a retailer with an online website Need a database to store user account details
More information(2,4) Trees. 2/22/2006 (2,4) Trees 1
(2,4) Trees 9 2 5 7 10 14 2/22/2006 (2,4) Trees 1 Outline and Reading Multi-way search tree ( 10.4.1) Definition Search (2,4) tree ( 10.4.2) Definition Search Insertion Deletion Comparison of dictionary
More informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationTrees, Part 1: Unbalanced Trees
Trees, Part 1: Unbalanced Trees The first part of this chapter takes a look at trees in general and unbalanced binary trees. The second part looks at various schemes to balance trees and/or make them more
More informationFollow these steps to get started: o Launch MS Access from your start menu. The MS Access startup panel is displayed:
Forms-based Database Queries The topic presents a summary of Chapter 3 in the textbook, which covers using Microsoft Access to manage and query an Access database. The screenshots in this topic are from
More informationReferences and Homework ABSTRACT DATA TYPES; LISTS & TREES. Abstract Data Type (ADT) 9/24/14. ADT example: Set (bunch of different values)
9// References and Homework Text: Chapters, and ABSTRACT DATA TYPES; LISTS & TREES Homework: Learn these List methods, from http://docs.oracle.com/javase/7/docs/api/java/util/list.html add, addall, contains,
More informationLaboratory Module Trees
Purpose: understand the notion of 2-3 trees to build, in C, a 2-3 tree 1 2-3 Trees 1.1 General Presentation Laboratory Module 7 2-3 Trees 2-3 Trees represent a the simplest type of multiway trees trees
More informationBinary Trees. BSTs. For example: Jargon: Data Structures & Algorithms. root node. level: internal node. edge.
Binary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from
More informationB.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1
Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished
More informationA7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS
A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered
More informationAnnouncements. Midterm exam 2, Thursday, May 18. Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps. Break around 11:45am
Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps
More informationBricks Documentation. Release 1.0. Germano Guerrini
Bricks Documentation Release 1.0 Germano Guerrini January 27, 2015 Contents 1 Requirements 3 2 Contents 5 2.1 Getting Started.............................................. 5 2.2 Basic Usage...............................................
More information(Refer Slide Time: 06:01)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 28 Applications of DFS Today we are going to be talking about
More informationOne of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while
1 One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while leaving the engine to choose the best way of fulfilling
More informationReferential Integrity and Other Table Constraints Ray Lockwood
DDL Referential Integrity and Other Table s Pg 1 Referential Integrity and Other Table s Ray Lockwood Points: Referential Integrity assuring tables remain properly linked by primary and foreign keys. Referential
More informationH2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views
1. (4 points) Of the following statements, identify all that hold about architecture. A. DoDAF specifies a number of views to capture different aspects of a system being modeled Solution: A is true: B.
More informationTrees & Hierarchies in SQL. Joe Celko Copyright 2009
Trees & Hierarchies in SQL Joe Celko Copyright 2009 Trees in SQL Trees are graph structures used to represent Hierarchies Parts explosions Organizational charts Three major methods in SQL Adjacency list
More informationDjango-Select2 Documentation. Nirupam Biswas
Nirupam Biswas Mar 07, 2018 Contents 1 Get Started 3 1.1 Overview................................................. 3 1.2 Installation................................................ 3 1.3 External Dependencies..........................................
More informationDirected Graph and Binary Trees
and Dr. Nahid Sultana December 19, 2012 and Degrees Paths and Directed graphs are graphs in which the edges are one-way. This type of graphs are frequently more useful in various dynamic systems such as
More informationData Structure. IBPS SO (IT- Officer) Exam 2017
Data Structure IBPS SO (IT- Officer) Exam 2017 Data Structure: In computer science, a data structure is a way of storing and organizing data in a computer s memory so that it can be used efficiently. Data
More informationCIS192 Python Programming
CIS192 Python Programming HTTP Requests and HTML Parsing Robert Rand University of Pennsylvania March 30, 2016 Robert Rand (University of Pennsylvania) CIS 192 March 30, 2016 1 / 19 Outline 1 HTTP Requests
More informationThe tree data structure. Trees COL 106. Amit Kumar Shweta Agrawal. Acknowledgement :Many slides are courtesy Douglas Harder, UWaterloo
The tree data structure 1 Trees COL 106 Amit Kumar Shweta Agrawal Acknowledgement :Many slides are courtesy Douglas Harder, UWaterloo 1 Trees The tree data structure 3 A rooted tree data structure stores
More informationdjango-conduit Documentation
django-conduit Documentation Release 0.0.1 Alec Koumjian Apr 24, 2017 Contents 1 Why Use Django-Conduit? 3 2 Table of Contents 5 2.1 Filtering and Ordering.......................................... 5
More informationPrinciples of Computer Science
Principles of Computer Science Binary Trees 08/11/2013 CSCI 2010 - Binary Trees - F.Z. Qureshi 1 Today s Topics Extending LinkedList with Fast Search Sorted Binary Trees Tree Concepts Traversals of a Binary
More informationHierarchical data structures. Announcements. Motivation for trees. Tree overview
Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps
More informationPart XII. Mapping XML to Databases. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321
Part XII Mapping XML to Databases Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 321 Outline of this part 1 Mapping XML to Databases Introduction 2 Relational Tree Encoding Dead Ends
More informationTrees. Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250
Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 https://ece.uwaterloo.ca/~cmoreno/ece250 Today's class: We'll discuss one possible implementation for trees (the general type of trees) We'll look at tree
More informationLecture 32. No computer use today. Reminders: Homework 11 is due today. Project 6 is due next Friday. Questions?
Lecture 32 No computer use today. Reminders: Homework 11 is due today. Project 6 is due next Friday. Questions? Friday, April 1 CS 215 Fundamentals of Programming II - Lecture 32 1 Outline Introduction
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 5 Exploring graphs Adam Smith 9/5/2008 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Puzzles Suppose an undirected graph G is connected.
More informationData structures. Priority queues, binary heaps. Dr. Alex Gerdes DIT961 - VT 2018
Data structures Priority queues, binary heaps Dr. Alex Gerdes DIT961 - VT 2018 Announcements Course representatives - Mohamad Qutbuddin Habib - Carl Agrell - Gunnar Stenlund Kunsulttid: jag är på kontor
More informationAlgorithms. Deleting from Red-Black Trees B-Trees
Algorithms Deleting from Red-Black Trees B-Trees Recall the rules for BST deletion 1. If vertex to be deleted is a leaf, just delete it. 2. If vertex to be deleted has just one child, replace it with that
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Binary search tree (part I) Version of March 24, 2013 Abstract These lecture notes are meant
More informationdjango-embed-video Documentation
django-embed-video Documentation Release 0.6.stable Juda Kaleta October 04, 2013 CONTENTS i ii Django app for easy embeding YouTube and Vimeo videos and music from SoundCloud. Repository is located on
More informationtreelib Documentation
treelib Documentation Release 1.3.0 Xiaming Chen Jul 08, 2018 Contents 1 Install 3 2 Useful APIs 5 2.1 Node Objects.............................................. 5 2.2 Tree Objects..............................................
More informationLecture 3: Graphs and flows
Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected
More informationGraph and Digraph Glossary
1 of 15 31.1.2004 14:45 Graph and Digraph Glossary A B C D E F G H I-J K L M N O P-Q R S T U V W-Z Acyclic Graph A graph is acyclic if it contains no cycles. Adjacency Matrix A 0-1 square matrix whose
More informationTools for Scalable Data Mining
Tools for Scalable Data Mining XANDA SCHOFIELD CS 6410 11/13/2014 1. Astrolabe Large, eventuallyconsistent distributed system ROBERT VAN RENESSE, KEN BIRMAN, WERNER VOGELS [Source: Wikipedia] The Problem
More informationtreelib Documentation
treelib Documentation Release 1.4.0 Xiaming Chen Dec 23, 2017 Contents 1 Install 3 2 Useful APIs 5 2.1 Node Objects.............................................. 5 2.2 Tree Objects..............................................
More informationAlgorithms: Lecture 10. Chalmers University of Technology
Algorithms: Lecture 10 Chalmers University of Technology Today s Topics Basic Definitions Path, Cycle, Tree, Connectivity, etc. Graph Traversal Depth First Search Breadth First Search Testing Bipartatiness
More informationCopyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1
Slide 27-1 Chapter 27 XML: Extensible Markup Language Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree) Data Model. XML Documents, DTD, and XML Schema.
More informationCE419 Web Programming. Session 15: Django Web Framework
CE419 Web Programming Session 15: Django Web Framework Web Applications & Databases In modern Web applications, the arbitrary logic often involves interacting with a database. Behind the scenes, a database-driven
More informationData Structures and Algorithms
Data Structures and Algorithms Trees Sidra Malik sidra.malik@ciitlahore.edu.pk Tree? In computer science, a tree is an abstract model of a hierarchical structure A tree is a finite set of one or more nodes
More information2-3 and Trees. COL 106 Shweta Agrawal, Amit Kumar, Dr. Ilyas Cicekli
2-3 and 2-3-4 Trees COL 106 Shweta Agrawal, Amit Kumar, Dr. Ilyas Cicekli Multi-Way Trees A binary search tree: One value in each node At most 2 children An M-way search tree: Between 1 to (M-1) values
More informationa graph is a data structure made up of nodes in graph theory the links are normally called edges
1 Trees Graphs a graph is a data structure made up of nodes each node stores data each node has links to zero or more nodes in graph theory the links are normally called edges graphs occur frequently in
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Binary search tree (part I) Version of March 24, 2013 Abstract These lecture notes are meant
More informationCS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13
CS121 MIDTERM REVIEW CS121: Relational Databases Fall 2017 Lecture 13 2 Before We Start Midterm Overview 3 6 hours, multiple sittings Open book, open notes, open lecture slides No collaboration Possible
More informationChapter 1 Readme.doc definitions you need to know 1
Contents Foreword xi Preface to the second edition xv Introduction xvii Chapter 1 Readme.doc definitions you need to know 1 Sample data 1 Italics 1 Introduction 1 Dimensions, measures, members and cells
More informationStructure and Interpretation of Computer Programs
CS 61A Fall 2016 Structure and Interpretation of Computer Programs Final INSTRUCTIONS You have 3 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator, except
More information8. Write an example for expression tree. [A/M 10] (A+B)*((C-D)/(E^F))
DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES UNIT IV NONLINEAR DATA STRUCTURES Part A 1. Define Tree [N/D 08]
More informationUNIT IV -NON-LINEAR DATA STRUCTURES 4.1 Trees TREE: A tree is a finite set of one or more nodes such that there is a specially designated node called the Root, and zero or more non empty sub trees T1,
More informationdjango-embed-video Documentation
django-embed-video Documentation Release 0.7.stable Juda Kaleta December 21, 2013 Contents i ii Django app for easy embeding YouTube and Vimeo videos and music from SoundCloud. Repository is located on
More information(Refer Slide Time: 05:25)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering IIT Delhi Lecture 30 Applications of DFS in Directed Graphs Today we are going to look at more applications
More informationAbstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department
Abstract Data Structures IB Computer Science Content developed by Dartford Grammar School Computer Science Department HL Topics 1-7, D1-4 1: System design 2: Computer Organisation 3: Networks 4: Computational
More informationStructure and Interpretation of Computer Programs
CS 61A Summer 2015 Structure and Interpretation of Computer Programs Final INSTRUCTIONS You have 3 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College October 19, 2016 Outline Outline 1 Chapter 7: Trees Outline Chapter 7: Trees 1 Chapter 7: Trees Uses Of Trees Chapter 7: Trees
More informationInput (part 2: input models)
Input (part 2: input models) Dealing with diversity Saw lots of diversity in devices actual details of devices (e.g., device drivers) is a real pain how do we deal with the diversity? Need a model (abstraction)
More informationDATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016
DATABASE SYSTEMS Introduction to MySQL Database System Course, 2016 AGENDA FOR TODAY Administration Database Architecture on the web Database history in a brief Databases today MySQL What is it How to
More informationFundamentals of Data Structure
Fundamentals of Data Structure Set-1 1. Which if the following is/are the levels of implementation of data structure A) Abstract level B) Application level C) Implementation level D) All of the above 2.
More information(2,4) Trees Goodrich, Tamassia (2,4) Trees 1
(2,4) Trees 9 2 5 7 10 14 2004 Goodrich, Tamassia (2,4) Trees 1 Multi-Way Search Tree A multi-way search tree is an ordered tree such that Each internal node has at least two children and stores d -1 key-element
More informationCSCI Trees. Mark Redekopp David Kempe
CSCI 104 2-3 Trees Mark Redekopp David Kempe Trees & Maps/Sets C++ STL "maps" and "sets" use binary search trees internally to store their keys (and values) that can grow or contract as needed This allows
More informationBasant Group of Institution
Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of
More informationStatements or Basic Blocks (Maximal sequence of code with branching only allowed at end) Possible transfer of control
Control Flow Graphs Nodes Edges Statements or asic locks (Maximal sequence of code with branching only allowed at end) Possible transfer of control Example: if P then S1 else S2 S3 S1 P S3 S2 CFG P predecessor
More informationA set of nodes (or vertices) with a single starting point
Binary Search Trees Understand tree terminology Understand and implement tree traversals Define the binary search tree property Implement binary search trees Implement the TreeSort algorithm 2 A set of
More informationCpt S 122 Data Structures. Data Structures Trees
Cpt S 122 Data Structures Data Structures Trees Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Motivation Trees are one of the most important and extensively
More informationMahathma Gandhi University
Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed
More informationLecture 3 February 9, 2010
6.851: Advanced Data Structures Spring 2010 Dr. André Schulz Lecture 3 February 9, 2010 Scribe: Jacob Steinhardt and Greg Brockman 1 Overview In the last lecture we continued to study binary search trees
More informationPartitioning Shines in PostgreSQL 11
Partitioning Shines in PostgreSQL 11 Amit Langote, NTT OSS Center PGConf.ASIA, Tokyo Dec 11, 2018 About me Amit Langote Work at NTT OSS Center developing PostgreSQL Contributed mainly to table partitioning
More informationTREES. Trees - Introduction
TREES Chapter 6 Trees - Introduction All previous data organizations we've studied are linear each element can have only one predecessor and successor Accessing all elements in a linear sequence is O(n)
More informationMedia Services Online Mohammed Abukhiran. Report 13 on the work of Week 13
Media Services Online Mohammed Abukhiran Report 13 on the work of Week 13 Berea College Nov 30, 2010 Application Development Project Concept Proposal Media Services at Berea College uses Voyger (Database
More informationFoundations of Discrete Mathematics
Foundations of Discrete Mathematics Chapter 12 By Dr. Dalia M. Gil, Ph.D. Trees Tree are useful in computer science, where they are employed in a wide range of algorithms. They are used to construct efficient
More informationNuxeo SQL Storage. Specifcation. Last Modifcation Version 1.1. Copyright 2008 Nuxeo. All Rights Reserved.
Nuxeo SQL Storage Specifcation Last Modifcation 2008-08-29 Project Code Document ID NUXEO NXSQL Version 1.1 Copyright Copyright 2008 Nuxeo. All Rights Reserved. History Version Date Participant(s) Comments
More informationIntroduction to Web Concepts & Technologies
Introduction to Web Concepts & Technologies What to Expect This is an introduction to a very broad topic This should give you a sense of what you will learn in this course Try to figure out what you want
More informationFriendlyShell Documentation
FriendlyShell Documentation Release 0.0.0.dev0 Kevin S. Phillips Nov 15, 2018 Contents: 1 friendlyshell 3 1.1 friendlyshell package........................................... 3 2 Overview 9 3 Indices
More informationWarm Up. Use Kruskal s algorithm to find the minimum spanning tree and it s weight.
Warm Up Use Kruskal s algorithm to find the minimum spanning tree and it s weight. Edge Weight (1,4) 1 (6,7) 1 (1,2) 2 (3,4) 2 (2,4) 3 (1,3) 4 (4,7) 4 (3,6) 5 (5,7) 6 1 Section 5.6 Binary Trees, Expression
More informationParallel Physically Based Path-tracing and Shading Part 3 of 2. CIS565 Fall 2012 University of Pennsylvania by Yining Karl Li
Parallel Physically Based Path-tracing and Shading Part 3 of 2 CIS565 Fall 202 University of Pennsylvania by Yining Karl Li Jim Scott 2009 Spatial cceleration Structures: KD-Trees *Some portions of these
More informationArbori Starter Manual Eugene Perkov
Arbori Starter Manual Eugene Perkov What is Arbori? Arbori is a query language that takes a parse tree as an input and builds a result set 1 per specifications defined in a query. What is Parse Tree? A
More informationDjango Groups Manager Documentation
Django Groups Manager Documentation Release 0.3.0 Vittorio Zamboni May 03, 2017 Contents 1 Documentation 3 1.1 Installation................................................ 3 1.2 Basic usage................................................
More informationEvaluating XPath Queries
Chapter 8 Evaluating XPath Queries Peter Wood (BBK) XML Data Management 201 / 353 Introduction When XML documents are small and can fit in memory, evaluating XPath expressions can be done efficiently But
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College November 13, 2017 Outline Outline 1 C++ Supplement.1: Trees Outline C++ Supplement.1: Trees 1 C++ Supplement.1: Trees Uses
More informationStructure and Interpretation of Computer Programs
CS 6A Fall 206 Structure and Interpretation of Computer Programs Final Solutions INSTRUCTIONS You have hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,
More informationTrees. Tree Structure Binary Tree Tree Traversals
Trees Tree Structure Binary Tree Tree Traversals The Tree Structure Consists of nodes and edges that organize data in a hierarchical fashion. nodes store the data elements. edges connect the nodes. The
More informationDatabase Management Systems Paper Solution
Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of
More informationFundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.
Chapter 5 Database Design Elements of Database Design Fundamentals, Design, and Implementation, 9/e Chapter 5/2 The Database Design Process Create tables and columns from entities and attributes Select
More informationTrees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.
Trees Q: Why study trees? : Many advance DTs are implemented using tree-based data structures. Recursive Definition of (Rooted) Tree: Let T be a set with n 0 elements. (i) If n = 0, T is an empty tree,
More information