• No results found

Data Abstraction and Problem Solving with JAVA: Data Abstraction and Problem Solving with JAVA: Walls and MirrorsWalls and Mirrors TreesTrees

N/A
N/A
Protected

Academic year: 2021

Share "Data Abstraction and Problem Solving with JAVA: Data Abstraction and Problem Solving with JAVA: Walls and MirrorsWalls and Mirrors TreesTrees"

Copied!
49
0
0

Loading.... (view fulltext now)

Full text

(1)

Data Abstraction and Problem Solving with JAVA:

Data Abstraction and Problem Solving with JAVA:

Walls and Mirrors Walls and Mirrors

Carrano / Prichard Carrano / Prichard

Trees

Trees

(2)

A general tree

(3)

A subtree of the tree in Figure 10.1

(4)

a) An organization chart; b) a family tree

(5)

Binary trees that represent algebraic expressions

(6)

A binary search tree of names

(7)

Binary trees with the same nodes but different heights

(8)

A full binary tree of height 3

(9)

A complete binary tree

(10)

Traversals of a binary tree: a) preorder; b) inorder; c) postorder

(11)

a) A binary tree of names

(12)

b) its array-based

implementations

(13)

Level-by-level numbering of a complete binary tree

(14)

An array-based implementation of the complete binary tree in Figure 10-11

(15)

A reference-based implementation of a binary tree

(16)

Contents of the implicit stack as treeNode progresses through a given tree

during a recursive inorder traversal

(17)

Traversing a) the left and b) the right subtrees of 20

(18)

Avoiding returns to nodes B and C

(19)

A binary search tree

(20)

Binary search trees with the same data as in Figure 10-17

(21)

Binary search trees with the same data as in Figure 10-17

(22)

Binary search trees with the same data as in Figure 10-17

(23)

An array of names in sorted order

(24)

Empty subtree where search terminates

(25)

a) Insertion into an empty tree; b) search terminates at a leaf

(26)

c) insertion at a leaf

(27)

a) N with only a left child—N can be either the left or right child of P; b) after

deleting node N

(28)

N with two children

(29)

Not any node will do

(30)

Search key x can be replaced by y

(31)

Copying the item whose search key is the inorder successor of N ’s search key

(32)

Recursive deletion of node N

(33)

A maximum-height binary tree with seven nodes

(34)

Binary trees of height 3

(35)

Counting the nodes in a full binary tree of height h

(36)

Filling in the last level of a tree

(37)

The order of the retrieval, insertion, deletion, and traversal operations for the

reference-based implementation of the ADT binary search tree

(38)

a) A binary search tree bst; b) the sequence of insertions that result in this tree

(39)

A full tree saved in a file by using inorder traversal

(40)

A tree of minimum height that is not complete

(41)

A general tree

(42)

A reference-based implementation of the general tree in Figure 10.36

(43)

The binary tree that Figure 10-37 represents

(44)

An implementation of the n-ary tree in Figure 10.36

(45)

A tree for Self-Test Exercises 1, 3, 7, and 11 and for Exercises 6 and 11

(46)

An array for Self-Test Exercise 9

(47)

A tree for Self-Test Exercise 10 and for Exercise 2a

(48)

A binary search tree for Exercise 3

(49)

A minimax tree for Exercise 17

References

Related documents

(Convince yourself that a left subtree with a balance factor equal to 0 at its root cannot occur in this case.) The necessary rebalancing operations

Unit3: Tree: binary tree, Binary Tree representations: node and implicit array representation, internal and external nodes, binary tree traversals, threaded binary

Laser diode manufacturing tends to be relatively labor intensive and manufacturers are constantly seeking ways to optimize the cost trade-off between fixed cost capital investments

Data Abstraction and Problem Solving with JAVA:.. Data Abstraction and Problem Solving

The results of a depth-first traversal, beginning at vertex a, of the graph in Figure 13-11... The results of a breadth-first traversal, beginning at vertex a, of the graph in

• In order to insert a new node in a binary tree, we have to be at a node with a vacant left or right child. • This is performed in the same way

Binary search trees provide an excellent structure for searching Binary search trees provide an excellent structure for searching a list and at the same time for inserting

Theorem 5 (Static Finger Theorem) Consider a sequence of m accesses in an n-node splay tree. Let a[j] denote the jth