lecture-13

In parent child relationships the parent of a node n

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: g of –  Zero or more nodes –  A distinguished “root” node (no parents) –  Structures of multiple trees are called “forests” the root D B A F C E G CPSC 223  ­ ­ Fall 2010 9 Trees (Terminology) Nodes are arranged in parent-child relationships –  The parent of a node N is directly above N –  The child of a node N is directly below N a parent of node B a child of node D D B A F C E CPSC 223  ­ ­ Fall 2010 G 10 5 10/14/10 Trees (Terminology) Each non-root node has exactly one parent Every node can have zero or more children –  A node without any children is called a “leaf” node   A node with children is called an “internal” node the root D an internal node a leaf node B A F C E G CPSC 223  ­ ­ Fall 2010 11 Trees (Terminology) A “path” is a sequence of nodes … –  The next node in the sequence after node N is a child of N –  we can obtain a path by starting at a node and following child edges until we reach a leaf a path D B A F C E CPSC 223  ­ ­ Fall 2010 G 12 6 10/14/10 Trees (Terminology) Parent-child relationships induce ancestor-descendent relationships –  An ancestor of a node N is either the parent of N or the parent of an ancestor of N –  The root is the ancestor of every node in the tree –  A descendent of a node N is either a child of N or a child of a descendent of N an ancestor of A A descendent of a node lies on a path from the node to a leaf D B a descendent of D A F C E G CPSC 223  ­ ­ Fall 2010 13 Trees (Terminology) Nodes can have zero or more “siblings” –  The siblings of N are the nodes with the same parent as N sibling of B D sibling of F B A CPSC 223  ­ ­ Fall 2010 F C E G 14 7 10/14/10 Trees (Terminology) A “subtree” is a tree rooted at a descendent of the root –  A subtree includes all children and descendents of the subtree “root” N –  We often say a subtree is rooted at N D subtree rooted at...
View Full Document

This document was uploaded on 03/18/2014 for the course CPSC 223 at Gonzaga.

Ask a homework question - tutors are online