Building Java Programs - University of Washington
嚜濁uilding Java Programs
Binary Trees
reading: 17.1 每 17.3
Trees
? tree: A directed, acyclic structure of linked nodes.
每 directed : Has one-way links between nodes.
每 acyclic : No path wraps back around to the same node twice.
每 binary tree: One where each node has at most two
children.
root
? Recursive definition: A tree is either:
每 empty (null), or
每 a root node that contains:
?
?
?
1
data,
a left subtree, and
a right subtree.
每
(The left and/or right
subtree could be empty.)
2
4
3
5
6
7
2
Trees in computer science
? folders/files on a computer
? family genealogy; organizational charts
? AI: decision trees
? compilers: parse tree
每 a = (b + c) * d;
? cell phone T9
=
a
*
+
b
d
c
3
Terminology
? node: an object containing a data value and left/right
children
? root: topmost node of a tree
? leaf: a node that has no children
? branch: any internal node; neither the root nor a leaf
root
? parent: a node that refers to this one
height = 3
? child: a node that this node refers to
level 1
? sibling: a node with a common parent
? subtree: the smaller tree of nodes on
level 2
the left or right of the current node
? height: length of the longest path
from the root to any node
level 3
? level or depth: length of the path
from a root to a given node
4
1
2
3
5
6
7
4
A tree node for integers
? A basic tree node object stores data, refers to left/right
? Multiple nodes can be linked together into a larger tree
left
data right
42
left
data right
59
left
data right
27
left
data right
86
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- building java programs university of washington
- binarysearch int a int key method example
- using recursion to convert number to other number bases
- lab a translating data to binary york university
- identifying java calls in native code via binary scanning
- binarysearch double a int fromindex int toindex
- the binaryreader and binarywriter java transformations
- binarysearch char a int fromindex int toindex
- networking with java university of arizona
- insert percolate up heap insert val university of washington
Related searches
- university of washington hr jobs
- university of washington jobs listing
- university of washington human resources
- university of washington human resources dept
- university of washington baseball roster
- university of washington product management
- university of washington online mba
- university of washington printable map
- university of washington opioid taper
- university of washington opioid calculator
- university of washington program management
- university of washington graduate programs