CC2203-Les11TreeI-for-viewing

CC2203-Les11TreeI-for-viewing - 11-1/71Lesson 11: Tree...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11-1/71Lesson 11: Tree I11-2/71Nature Lover’s View Of A Treerootbranchesleaves11-3/71Computer Scientist’s Viewbranchesleavesrootnodes11-4/71great grand child of rootgrand children of rootchildren of rootJava’s ClassesObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeExceptionrootleaf11-5/71Definition• A tree t is a finite nonempty set of elements.• One of these elements is called the root.• The remaining elements, if any, are partitioned into trees, which are called the subtrees of t.11-6/71SubtreesObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeExceptionroot11-7/71LeavesObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeException11-8/71Parent, Grandparent, Siblings, Ancestors, DescendantsObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeExceptionChildren of the same parent are called siblings11-9/71Level 4Level 3Level 2LevelsObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeExceptionLevel 111-10/71Caution• Some texts start level numbers at 0 rather than at 1 (e.g. The textbook by Hubbard and Huray)• We shall number levels as follows:• Root is at level 1.• Its children are at level 2.• The grand children of the root are at level 3.• And so on.11-11/71height = depth = highest level numberLevel 4Level 3Level 2ObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeExceptionLevel 1Height of empty tree is 0Height of a single-node tree is 111-12/71Node Degree = Number Of ChildrenObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeException3211111-13/71Tree Degree = Max Node DegreeObjectNumberThrowableOutputStreamIntegerDoubleExceptionFileOutputStreamRuntimeException32111Degree of tree = 3.11-14/71Binary Tree• Finite (possibly empty) collection of elements.• A nonempty binary tree has a root element.• The remaining elements (if any) are partitioned into two binary trees.• These are called the left and right subtrees of the binary tree.11-15/71Differences Between A Tree & A Binary Tree• No node in a binary tree may have a degree more than 2, whereas there is no limit on the degree of a node in a tree.11-16/71Differences Between A Tree & A Binary Tree• The subtrees of a binary tree are ordered; those of a tree are not ordered.abab• Are different when viewed as binary trees.• Are the same when viewed as trees.11-17/71Arithmetic Expressions• (a + b) * (c + d) + e – f/g*h + 3.25• Expressions comprise three kinds of entities.– Operators (+, -, /, *).– Operands (a, b, c, d, e, f, g, h, 3.25, (a + b), (c + d),etc.).– Delimiters ((, )).11-18/71Operator Degree• Number of operands that the operator requires....
View Full Document

Page1 / 71

CC2203-Les11TreeI-for-viewing - 11-1/71Lesson 11: Tree...

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

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