Title: BINARY TREE
1BINARYTREE
- Ma. Leonisa C. Reyes
- MSIT 127 10-02-04
2Tree Structure
- Is one of the very useful data structures since
it can control complex data better than array-or
list-type data structures - Because it has a hierarchical structure like a
company organization or a family tree, it is
suited for the type of work involving
step-by-step classification
3Tree Structure Elements
- Node correspond to data
- Branch connecting one node to the other
- Root highest-order node that has no parent
- Child node that braches off under a node
- Parent original data before it begins to branch
- Leaf lowest-order node that has no child
4TREE DATA STRUCTURE
5- tree
- A tree is either
- empty (no nodes), or
- a root and zero or more subtrees (subtrees are
ordered)
6A data structure accessed beginning at the root
node. Each node is either a leaf or an internal
node. An internal node has one or more child
nodes and is called the parent of its child
nodes. All children of the same node are
siblings. Contrary to a physical tree, the root
is usually depicted at the top of the structure,
and the leaves are depicted at the bottom.
7child An item of a tree referred to by a parent
item.
leaf A terminal or "bottom" item of a tree. Also
known as external node, terminal node.
node A unit of reference in a data structure.
Also called a vertex in graphs and trees. A
collection of information which must be kept at a
single memory location.
root The distinguished initial or fundamental
item of a tree. The only item which has no
parent.
null tree A tree which is empty. A tree whose
leaf nodes all have a null value.
parent Of a node the tree node conceptually
above or closer to the root than the node and
which has a link to the node.
8- binary tree
- A tree with at most two children for each node.
- A binary tree is either
- empty (no nodes), or
- has a root node, a left binary tree, and a right
binary tree.
9- Binary-tree data consists of one data section and
two pointer sections. - The left pointer section shows the position of a
node that extends to the left and branches off
while the right pointer section shows the
position of node that extends to the right and
branches off.
10Binary Search Tree
- A binary search tree is used as a variant of a
binary tree. - In the case of a binary search tree, a descendant
to the left is smaller than a parent and a
descendant to the right is larger than a parent.
11The Algorithm of a binary search tree
- a root is a point where a search starts
- binary-tree data is compared with data to search
- if binary-tree data data to search, a search is
successful (completed) - if binary-tree data gt data to search, nodes to
the left of a binary tree are searched and
compared - if binary-tree data lt data to search, nodes to
the right of a binary tree are searched and
compared - if no child is found, a search is unsuccessful
(no data is found)
12Demonstration of a Search in a Binary Search
Tree
http//www-1g.cs.luc.edu/mhg/demos/BinarySearchTr
ee/
13Binary Tree
http//www.cs.jhu.edu/goodrich/dsa/trees/btree.ht
ml
Standard Binary Search Tree
http//www.ibr.cs.tu-bs.de/lehre/ss98/audii/applet
s/BST/BST-Example.html
14good evening!