0% found this document useful (0 votes)
20 views

CSC-335 ADT's & Data Structures - Searching: Binary Trees)

This document provides an overview of binary trees and their representation in arrays. It discusses that binary trees are a data structure where each node has at most two children, and they are useful for modeling processes with two possible outcomes. It notes that while array representation works for complete binary trees, it is not efficient for sparse trees. The document also introduces the concept of balanced versus unbalanced binary trees, where balanced trees have exactly two children per node except leaves, while unbalanced trees may have nodes with different numbers of children.

Uploaded by

frankjamison
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

CSC-335 ADT's & Data Structures - Searching: Binary Trees)

This document provides an overview of binary trees and their representation in arrays. It discusses that binary trees are a data structure where each node has at most two children, and they are useful for modeling processes with two possible outcomes. It notes that while array representation works for complete binary trees, it is not efficient for sparse trees. The document also introduces the concept of balanced versus unbalanced binary trees, where balanced trees have exactly two children per node except leaves, while unbalanced trees may have nodes with different numbers of children.

Uploaded by

frankjamison
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 7

CSC-335 ADTs & Data Structures

(Chapter 12 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

If the tree is nonempty


one of the nodes (the root) has no incoming arc every other node can be reached by following a unique sequence of consecutive arcs

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

Store the ith node in the ith location of the array


4

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

You might also like