day15 - COP 3503 Computer Science II CLASS NOTES DAY#15...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3503 – Computer Science II CLASS NOTES - DAY #15 Trees differ from linked list in one important way, they are not linear structures. Linked lists are inherently linear in their structure regardless of the number of lists in which a particular node participates (multiply linked lists). Traversal in a linear list always proceeds from a particular node to either its logical predecessor or successor node. Only the implementation of the list will affect which node is the logical successor or predecessor node. A linked list cannot easily represent data which is hierarchical in nature. Hierarchical data exhibits ancestor-descendant, superior-subordinate, whole-part, or similar relationships among the data elements. The Java class hierarchy is an example of such a relationship. As with the linked list, it is possible to represent a tree using a static data structure although this is not common. There is however, one instance where a static implementation is commonly used for the purposes of speed of retrieval and we will examine this special case later (actually it concerns a special case of a binary tree). The most common implementation of a tree is done dynamically and this is the implementation we will focus upon. Before we examine the actual implementation issues surrounding trees, we need to focus on what exactly is a tree. There are actually two different approaches to defining a tree structure, one is a recursive definition and the other is a non-recursive definition. The non-recursive definition basically considers a tree as a special case of a more general data structure, the graph . In this definition the tree is viewed to consist of a set of nodes which are connected in pairs by directed edges such that the resulting graph is connected (every node is connected to a least one other node – no node exists in isolation) and cycle-free. This general definition does not specify that the tree have a root and thus a rooted-tree is a further special case of the general tree such every one of the node except the one designated as the root is connected to at least one other node. In certain situations the non-recursive definition of a tree has certain advantages, however, for our purposes we will focus on the recursive definition of a tree which is: Day 15 - 1 Tree Implementations
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
A complete set of terminology has evolved for dealing with trees and we’ll look at some of this terminology so that we too can discuss tree structures with some degree of sophistication. As you will see the terminology of trees is derived from mathematical, genealogical, and botanical disciplines. Rooted Tree: (from the non-recursive definition) A tree in which one node is specified to be the root , (call it node c ). Every node (other than c ), call it b is connected by exactly one edge to exactly one other node, call it p .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 18

day15 - COP 3503 Computer Science II CLASS NOTES DAY#15...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online