CSC-335 ADT's & Data Structures - Searching: Binary Trees)
CSC-335 ADT's & Data Structures - Searching: Binary Trees)
The content of this power point lecture has been originally created by Christos Kolonis and modified by Dr. Ahmad R Hadaegh
Trees
A data structure which consists of
a finite set of elements called nodes or vertices a finite set of directed arcs which connect the nodes
Binary Trees
Each node has at most two children Useful in modeling processes where
a comparison or experiment has exactly two possible outcomes the test is performed repeatedly
Example
multiple coin tosses encoding/decoding messages in dots and dashes such as Mores code
Array Representation of Binary Trees Works OK for complete trees, not for sparse trees
Problem of Lopsidedness
Tree can be balanced
each node except leaves has exactly 2 child nodes
Problem of Lopsidedness
Trees can be unbalanced
not all nodes have exactly 2 child nodes