0% found this document useful (0 votes)
24 views2 pages

Slot9 Tree Writing

The document provides a set of exercises on binary trees including: 1) Drawing preorder, inorder, postorder, and level-order traversals of sample binary trees. 2) Creating binary search trees from key insertion sequences and providing the traversals. 3) Creating AVL trees from key insertion sequences and providing the traversals. 4) Deleting a node from an AVL tree to maintain balance. 5) Identifying values of n for which a nearly complete binary tree is full or complete. 6) Determining if a given node examination sequence could occur during a search.

Uploaded by

Đức Trung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Slot9 Tree Writing

The document provides a set of exercises on binary trees including: 1) Drawing preorder, inorder, postorder, and level-order traversals of sample binary trees. 2) Creating binary search trees from key insertion sequences and providing the traversals. 3) Creating AVL trees from key insertion sequences and providing the traversals. 4) Deleting a node from an AVL tree to maintain balance. 5) Identifying values of n for which a nearly complete binary tree is full or complete. 6) Determining if a given node examination sequence could occur during a search.

Uploaded by

Đức Trung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

4-Binary Trees

Note: You can select and do some options according to your ability only. We
would like to note you that the more questions you do the better for you in doing
final practical and writing exams.

Writing exercises
1. Give the preorder, inorder, postorder,and level-order traversals of the following
binary trees.

(a) (b)

(c)

2. For each of the following key sequences create the binary search tree obtained
when the keys are inserted one-by-one in the order given into an initially empty
tree:
(1) 4, 3, 1, 11, 5, 9, 2, 6, 15, 12.
(2) 12, 7, 1, 3, 2, 5, 10, 8, 6, 9.
Give the preorder, inorder, postorder,and level-order traversals of the created
binary trees.
In (1) delete keys 2, 3 and 11. In (2) delete keys 5, 6 and 7. After each time of
deleting, give the above traversals.

3. For each of the key sequences in question 2 create the AVL tree obtained
when the keys are inserted one-by-one in the order given into an initially empty
tree.
Give the preorder, inorder, postorder,and level-order traversals of the created
binary trees.
4. The tree (c) in question 1 is height balanced (AVL). Delete the node D and
perfom necessary operations so that the tree is still AVL after deletion.

5. Consider a nearly complete binary tree with n nodes.


a. For what values of n is a nearly complete binary tree a full binary tree?
b. For what values of n is a nearly complete binary a complete (perfect) binary
tree?

6. Suppose we have numbers between 1 and 100 in a binary search tree and we
want to search for the number 57 in the tree. Could the following sequence be the
sequence of nodes to be examined?
2, 90, 63, 70, 68, 72, 57

You might also like