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

Applications of Binary Trees

The document discusses several applications of binary trees including expression trees, decision trees, Huffman coding trees, and game trees. Expression trees represent arithmetic expressions with operands at the leaves and operators at internal nodes. Decision trees classify data with decision nodes testing attributes and branches leading to class labels. Huffman coding trees generate optimal prefix codes for data compression. Game trees model game states in games like tic-tac-toe to determine the best next move.

Uploaded by

gopi9966957145
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views

Applications of Binary Trees

The document discusses several applications of binary trees including expression trees, decision trees, Huffman coding trees, and game trees. Expression trees represent arithmetic expressions with operands at the leaves and operators at internal nodes. Decision trees classify data with decision nodes testing attributes and branches leading to class labels. Huffman coding trees generate optimal prefix codes for data compression. Game trees model game states in games like tic-tac-toe to determine the best next move.

Uploaded by

gopi9966957145
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Applications of Binary Trees:

There is a vast set of applications of the binary tree in addition to searching.


The various applications of a binary tree are gaming, expression tree, Huffman tree
for coding, and decision trees.

1. Expression Tree:
A binary tree storing or representing an arithmetic expression is called as
expression tree.

 The leaves of an expression tree are operands.


 Operands could be variables or constants.
 The branch nodes (internal nodes) represent the operators.

A binary tree is the most suitable one for arithmetic expressions as it contains either
binary or unary operators. The expression tree for expression E, is shown in Fig.

2. 2. Decision tree:
The decision tree is a classifier in the form of a tree where each node is either a
branch node or a leaf node. Here the leaf node denotes the value of the target
attribute (class) of examples and the branch node is a decision node that denotes
some test to be carried out and takes a decision based on a single attribute value,
with one branch and sub tree for each possible outcome of the test.
For example, after testing a Boolean expression in an if statement ( C++) , the
program may execute the statements following it or the statements in the
corresponding else part.

We can visualize these different ways in which a program may execute through a
decision tree.

3. Huffman’s coding:

One of the most important applications of the binary tree is in communication.


Consider an example of transmitting an English text. We need to represent this text
by a sequence of 0s and 1s.

Let us consider an example. Let us use the sequence 00 to represent the letter ‘a’,
01 to represent letter ‘n’, and 0001 to represent the letter‘t’.

Suppose we want to transmit a text ‘an’ by transmitting the sequence 0001.


Now, at the receiving end, it is difficult to determine whether the transmitted
sequence was ‘an’ or ‘t’.
This is because 00 is a prefix of the code 0001. We must assign variable sequences
to the letters such that no code is the prefix of the other. A set of sequences is said
to be a prefix code if no sequence in the set is the prefix of another sequence in set.

For example, the set {000, 001, 01, 10, 11} is a prefix code,
whereas the set {1, 00, 000, 0001} is not.

One of the most useful applications of


binary tree is in generating the prefix codes for a given binary tree.
D.A. Huffman has given an elegant procedure to construct an optimal binary tree.

4. Game Trees:
One of the most exciting applications of trees is in games such as tic-tac-toe, chess,
nim, checkers, go, and so on.

We shall consider tic-tac-toe as an example for explaining this application of trees.


The game starts with an empty board and each time a player tries for the best move
from the given board position. Each player is initially assigned a symbol of either 'X'
or 'O'. Depending on the board position the user has to decide how good the
position seems to be for a player.

You might also like