# trees1(1) - Trees Examples of Tree structure Definition of...

This preview shows pages 1–5. Sign up to view the full content.

1 Trees Examples of Tree structure Definition of trees Binary tree Height of tree Tree traversals Finding max Finding sum

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

View Full Document
2 Trees You have seen that using linked lists you can represent an ordered collection of values without using arrays. Although linked lists require more memory space than arrays ( as they have to store address at each node), they have definite advantages over arrays. Insertion and deletion of items can be carried out with out involving considerable movement of data. The ordering relationship amongst a set of values is obtained through use of pointers. However, we need not restrict ourselves to only linear structures. In this chapter we shall extend the use of pointers to define a non-linear structure to model hierarchical relationships, such as a family tree. In such a tree, we have links moving from an ancestor to a parent, and links moving from the parent to children. We have many other examples of tree-structured hierarchies. Directory Hierarchies : In computers, files are stored in directories that form a tree. The top level directory represents the root. It has many subdirectories and
3 files. The subdirectories would have further set of subdirectories. Organization charts: In a company a number of vice presidents report to a president. Each VP would have a set of general managers, each GM having his/her own set of specific managers and so on. Biological classifications : Starting from living being at the root, such a tree can branch off to mammals, birds, marine life etc. Game Trees: All games which require only mental effort would always have number of possible options at any position of the game. For each position, there would be number of counter moves. The repetitive pattern results in what is known a game tree. Tree as a data structure A tree is a data structure that is made of nodes and pointers, much like a linked list. The difference between them lies in how they are organized: The top node in the tree is called the root and all other nodes branch off from this one.

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

View Full Document
4 Every node in the tree can have some number of children. Each child node can in turn be the parent node to its children and so on. Child nodes can have links only from a single parent. Any node higher up than the parent is called an ancestor node. Nodes having no children are called
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 24

trees1(1) - Trees Examples of Tree structure Definition of...

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

View Full Document
Ask a homework question - tutors are online