10b - TreesSlides

# 14 but binary search trees are not the only sort of

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: earch and dynamic memory allocation. 14 But binary search trees are not the only sort of binary trees. There do exist binary trees without the order condition on the nodes. Sometimes there are other requirements (see heaps soon) other requirements (see heaps soon). The insertion, deletion and location rules for search trees do not apply. These trees have different member functions. For example, consider the expression tree. expression Any expression involving binary operators can be Any expression involving binary operators can be represented represented by a binary tree. Here are some examples. The iterators and traversals do. A simple expression like We can make up complicated expressions like 6*2+7+8*3-6/7 6*2 can be expressed as + * / + 2 6 The operator is the root and the operands are its two children. Each simple operand is a leaf; two leaves are joined by an operator; two expressions are joined by parent operators – the tree is built upwards. We need a method of joining trees. + / + 6 2 6 * 7 * 7 * 8 6 2 6 * 8 7 3 ((((6*2)+7)+(8*3))((((6*2)+7)+(8*3))-(6/7)) Inorder traversal yields the origi...
View Full Document

## This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online