CSC148H1 Lecture Notes - Lecture 8: Longest Path Problem, The Item, The Leaves
katrinasavvy and 38715 others unlocked
1
CSC148H1 Full Course Notes
Verified Note
1 document
Document Summary
While lists are a really useful data structure, not all data has a natural linear order. In computer science, we have use a tree data structure to represent this type of data. Trees are a recursive data structure, with the following definition: A tree can have a root value connected to any number of other trees, called the subtrees of the tree. Intuitively, the root of the tree is the item which is located at the top of the tree; the rest of the tree consists of subtrees which are attached to the root. Note that a tree can contain a root value but not have any subtrees: this would represent a tree that contains just a single item. Every non-empty tree has a root node (which is generally drawn at the top of the tree), connected to zero or more subtrees. The root node of the above tree is labelled a.