7.2-binary_tree

# 7.2-binary_tree - CMPT 225 Binary Tree CMPT 225 Bin-ary...

This preview shows pages 1–6. Sign up to view the full content.

CMPT 225 Binary Tree

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CMPT 225 Bin-ary Tree • Definition: N-ary tree where N = 2 • Property: If binary tree T has height H then T has between H and 2 H -1 nodes
CMPT 225 Binary Tree Operations • Create a Binary Tree • Empty binary tree • 1 node binaby tree (root) • Insert a subtree as left subtree of root • Insert a subtree as right subtree of root • Remove left subtree of root • Remove right subtree of root • Size of Binary Tree (# of elements stored in Binary Tree)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CMPT 225 Insertion • Insert an element into a Binary Tree? • How does this operation work? • Answer: • Given a root, we can insert an element as either its left or its right subtree • Throw an exception if there is already a subtree
CMPT 225 Removal • Remove an element from a Binary Tree? • How does this operation work? • Answer: • Given a root, we can remove either its left or its right subtree • Throw an exception if there are no left/right subtrees • However, if we want to remove a specific element,

This preview has intentionally blurred sections. Sign up to view the full version.

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

## This note was uploaded on 01/29/2012 for the course CMPT 225 taught by Professor Annelavergne during the Summer '07 term at Simon Fraser.

### Page1 / 7

7.2-binary_tree - CMPT 225 Binary Tree CMPT 225 Bin-ary...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online