L12_Tree - Trees Page 1 of 74 Trees Leaf Leaf Leaf Leaf...

Info iconThis preview shows pages 1–21. Sign up to view the full content.

View Full Document Right Arrow Icon
Trees Page 1 of 74
Background image of page 1

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

View Full DocumentRight Arrow Icon
Trees L L e e a a f f R R o o o o t t L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f Page 2 of 74
Background image of page 2
Trees L L e e a a f f R R o o o o t t L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f L L e e a a f f Page 3 of 74
Background image of page 3

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

View Full DocumentRight Arrow Icon
Trees R R o o o o t t Page 4 of 74
Background image of page 4
This is pretty abstract… Are there any concrete examples? Page 5 of 74
Background image of page 5

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

View Full DocumentRight Arrow Icon
Source: www.royal.gov.uk/files/pdf/Windsor%20family%20tree.pdf Page 6 of 74
Background image of page 6
Source: www.info.gov.hk/graphics/cht_e.gif Page 7 of 74
Background image of page 7

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

View Full DocumentRight Arrow Icon
Terminologies a b Nodes d , e and f are the sib- lings . e f m d k j c g Node c is the parent of nodes g and h . Nodes g and h are the chil- dren of node c . h The words ancestor and de- scendant have the same meaning as they do in English. Page 8 of 74
Background image of page 8
Terminologies Node a is the root of the tree. a b e f m d k j c g h 9 of 74 Height = 4 Nodes d , b , f and c are the interior nodes of the tree. Nodes j , k , e , m , g and h are the leaves of the tree. Page
Background image of page 9

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

View Full DocumentRight Arrow Icon
Terminologies An empty tree. A tree of height 1. a A tree of height 2. a c b Page 10 of 74
Background image of page 10
Terminologies a b A subtree of the tree. Node c is the root of the subtree. d k j e f m c g h Page 11 of 74
Background image of page 11

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

View Full DocumentRight Arrow Icon
Binary Trees Each node in the tree has 0, 1, or 2 children. Every node except the root is said to be either a left child or a right child of its parent. Page 12 of 74
Background image of page 12
Binary Trees These two binary trees are different: Page 13 of 74
Background image of page 13

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

View Full DocumentRight Arrow Icon
Binary Search Trees Binary Search Trees are Binary Trees that satisfy two conditions. Page 14 of 74
Background image of page 14
Binary Search Trees 0123849 Key values are unique. At every node, the key value must be greater than all the keys in the left subtree, and less than all the keys in the right sub- tree. Ben/CC/ACE 0134219 Jack/SC/ELE 0120730 Bob/UC/SEG 0170980 Tom/SC/INE 0120739 Will/CC/CSC 0160039 Sue/UC/IDE 0147723 May/NA/IEG 0150957 Mary/CC/CEG 0114938 John/NA/CSC Page 15 of 74
Background image of page 15

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

View Full DocumentRight Arrow Icon
Searching a Binary Search Tree 0134219 Ben/CC/ACE Bob/UC/SEG 0170980 Jack/SC/ELE 0120730 0120739 Tom/SC/INE Will/CC/CSC 0160039 Sue/UC/IDE 0147723 May/NA/IEG 0150957 Mary/CC/CEG 0114938 John/NA/CSC 0123849 0134219 Page 16 of 74
Background image of page 16
Searching a Binary Search Tree Jack/SC/ELE 0120730 Tom/SC/INE 0120739 0123849 John/NA/CSC 0114938 Mary/CC/CEG 0150957 May/NA/IEG 0147723 Sue/UC/IDE 0160039 Will/CC/CSC 0170980 Bob/UC/SEG 0134219 Ben/CC/ACE 0120739 Page 17 of 74
Background image of page 17

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

View Full DocumentRight Arrow Icon
Searching a Binary Search Tree Ben/CC/ACE 0134219 Jack/SC/ELE 0120730 Bob/UC/SEG 0170980 Tom/SC/INE 0120739 Mary/CC/CEG 0114938 0123849 John/NA/CSC 0150957 May/NA/IEG 0160039 Will/CC/CSC 0153009 Sue/UC/IDE 0147723 Page 18 of 74
Background image of page 18
Searching a Binary Search Tree Page 19 of 74 0134219 Ben/CC/ACE 0134219 Jack/SC/ELE 0120730 Bob/UC/SEG 0170980 Tom/SC/INE 0120739 Will/CC/CSC 0160039 Sue/UC/IDE 0147723 May/NA/IEG 0150957 Mary/CC/CEG 0114938 John/NA/CSC 0123849
Background image of page 19

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

View Full DocumentRight Arrow Icon
Tree Page 20 of 74 0134219 Ben/CC/ACE 0134219 Jack/SC/ELE 0120730 Bob/UC/SEG 0170980 Tom/SC/INE 0120739 Will/CC/CSC 0160039 Sue/UC/IDE 0147723 May/NA/IEG 0150957 Mary/CC/CEG 0114938 John/NA/CSC 0123849
Background image of page 20
Image of page 21
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/28/2010 for the course CSC CSC1110 taught by Professor Cjyuan during the Fall '06 term at CUHK.

Page1 / 74

L12_Tree - Trees Page 1 of 74 Trees Leaf Leaf Leaf Leaf...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online