assignment2short - threads pointing at them. What is the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall 2011 CMSC 420 Samet SHORT ASSIGNMENT NUMBER 2 1. Is it true that the leaf nodes appear in the same relative order for the preorder, inorder, and postorder traversals of a binary tree? 2. Calculate the total number of leaf nodes in a tree having a i nodes of degree i (1 i n ). 3. Suppose that you are given the inorder and preorder traversals of a binary tree. Can you reconstruct the binary tree? 4. Describe the set of binary trees whose preorder and inorder traversals appear in the same order. 5. De±ne an extended binary tree to be a binary tree such that each of its non-empty nodes has two sons. This means that every leaf node has a null left son and a null right son. Nodes in the original tree that only have a left son are assigned a null right son in the extended binary tree. Nodes in the original tree that only have a right son are assigned a null left son in the extended binary tree. Prove that a binary tree of n nodes has n + 1 null sons. 6. Consider a binary tree that is threaded in inorder. Note that some nodes have several
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: threads pointing at them. What is the maximum number of threads that can point at a node? Describe the binary trees that can cause these situations to arise. 7. Describe how to ±nd the inorder predecessor of an arbitrary node P in a binary tree that is threaded in inorder. 8. Devise an algorithm to traverse a binary tree in inorder that does not make use of a stack or threads. You may temporarily change the values of the pointer ±elds during this process. However, at the end of the algorithm all pointer ±elds are to have the values they had prior to the invocation of the algorithm. You may make use of an additional one-bit FLAG ±eld in each node for auxiliary storage. The following exercises from the “Notes on Data Structures” are optional. You are urged to look at them for practice. 6, 7, 8, 32, 33, 36, 37, 10, 11, 12, 13, 14, 15, 16, 17, 42, 43, 18, 19, 20, 21, 44, 45...
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 420 taught by Professor Staff during the Fall '08 term at Maryland.

Ask a homework question - tutors are online