trees - Trees Day 1 Day 2 Introduction So far all data...

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

View Full Document Right Arrow Icon
Trees Day 1 , Day 2 Introduction So far, all data structures have been "linear": items follow one after another Next comes trees: number of items following another item may vary Advantages: Insert/delete are fast; find is fast (usually) Tree Basics What is a tree? Consider the following example: Terms Node: data (the value we actually care about) and key (the value used to find the data), plus branches to other nodes. All of the above circles are considered to be nodes of the tree Edges: The "branches" mentioned above. An edge is each line drawn in the image. The branches are usually considered to be directional: if you have an edge from A to D, you are not allowed to follow the edge back from D to A. Each branch leads to a child . B - N are all children of some kind. All of the fellow children are known as siblings . B, C, and D are all siblings. All siblings have a common parent . However, a child is usually not aware of its parent: instead, parents keep track of only their parents. B, C, and D all have the common parent, A. A node is only allowed to have one parent. There is a special node which has no parent: the root . Above, A is the root node. The number of children a node has is the the degree . A and J are of degree 3; K is of degree 0: it has no children. Some nodes have no children: these are known as leafs . E, G, K, L, M, and N are all leafs.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

trees - Trees Day 1 Day 2 Introduction So far all data...

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

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