1 / 18

Trees

Trees. Example Tree. Formal Definition (from Google’s define:tree ). In graph theory, a directed acyclic graph (DAG) in which the root node has no parent and every other node has exactly one parent. www.mindspring.com/~scarlson/tc/glossary.htm

jaden
Download Presentation

Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Trees

  2. Example Tree

  3. Formal Definition (from Google’s define:tree) • In graph theory, a directed acyclic graph (DAG) in which the root node has no parent and every other node has exactly one parent.www.mindspring.com/~scarlson/tc/glossary.htm • In computer science, a tree is a widely-used computer data structure that emulates a tree structure with a set of linked nodes. Each node has zero or more child nodes, which are below it in the tree (in computer science, unlike in nature, trees grow down, not up). A node that has a child is called the child's parent node. A child has at most one parent; a node without a parent is called the root node (or root). Nodes with no children are called leaf nodes. en.wikipedia.org/wiki/Tree_(computing)

  4. Tree Terminology

  5. Uses of Trees • Paragraph Numbering in a Document • Family (aSexual reproduction!) • File system e.g. Unix, Dos • Classification e.g. Linaus, Dewey • Hierarchical Database e.g. IBMs MIS, LDAP • Web site structure • Hierarchical Menu • Organisational Hierarchy • Class Hierarchy in Java • Assembly / Part hierarchy • Document Object Model • XML • B-tree for efficient indexing

  6. Legal Numberingin a document

  7. Family TerminologyFor object F:

  8. File system • File system in Unix or Windows • C:\Program Files\eXist\webapp\admin\admin.xql • Actually this is a ‘Forest’ of trees, each drive a separate Tree

  9. Folder Hierarchy

  10. Navigation in File System(from F)

  11. Taxonomy • Animal Kingdom • Home Kingdom Animalia Phylum Arthropoda Class Insecta Order Lepidoptera Suborder Macrolepidoptera Family Nymphalidae Species Vanessa atalanta • Knowledge • Dewey Decimal Classification • Finding Butterflies

  12. Type (A Kind of) Hierarchyrelative to F G and H would inherit all the attributes and methods of F and define additional attributes and methods of their own.  A type hierarchy allows sharing of definitions. [see ‘Normalisation’ Easily confused with an Object Hierarchy or Whole/Part hierarchy.

  13. Object Hierarchy • An object hierarchy supports one or more of a number of kinds of relationship. • Containment: • One object is ‘contained’ within, is a part of,  a parent object.  A containment relationship is used to move, copy or delete a whole sub-tree. • Scoping: • Names of objects must be unique within some scope. Often these scopes are hierarchical.  The name of a child is unique within the scope of the parent.  • Delegation: (cascading, value inheritance  • A child object delegates responsibility for a property to its parent, and so on up the hierarchy until an object defines the property.  • Aggregation: • A parent object has properties determined by the properties of its children.  For example, the value of the ‘cost’ in a non-leaf would be defined as the sum of cost values over all children, with actual cost values defined at the leaves. Min, max, average are other aggregate relationships. • Distribution: • A parent property is distributed over the children – for example a budget value defined in the parent is distributed over the children.

  14. HTML Document (Object Tree) <html> <head> <title>Sample Document</title> </head> <body> <h1>An HTML Document</h1> <p>This is a <i>simple</i> document. </p> </body> </html> From Flanagan,D. (2002) JavaScript The Definitive Guide , O’Reilly [on-line]

  15. DOM Class Tree From Flanagan,D. (2002) JavaScript The Definitive Guide , O’Reilly [on-line]

  16. Exercise • file:///C:/Inetpub/wwwroot/a-xslt/xpathviz/XPathMainNS.htm

  17. Exercises(based on hoax.xml) • Write XPath expressions to locate the following: • The recipe title • All recipe ingredients • The amount of brown sugar • The last instruction • Write DOM code to access the same data

More Related