Question

Suppose T is a binary search tree of height 4 (including the external nodes) that is...

Suppose T is a binary search tree of height 4 (including the external nodes) that is
storing all the integers in the range from 1 to 15, inclusive. Suppose further that
you do a search for the number 11. Explain why it is impossible for the sequence
of numbers you encounter in this search to be (9, 12, 10, 11).

Homework Answers

Answer #1

Answer :

1) In a BST all the nodes in the left sub-tree of the current node are smaller than the current node and all the nodes in the right sub-tree are greater than the current node. While searching for an element in the tree either the nodes visited have decreasing or increasing order of elements not both.

2) Algorithm to find smallest element in BST: Traverse from root till leaf node by recurring to left child of the current node.

smallest(T)

- Start from root node

- If currentNode->left is null:

return currentNode->data

else

smallet(currentNode->left)

Running time is equal to height of the tree, if number of elements are N then time complexity would be O(logN)

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*end*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. a) Suppose that a binary tree of height h has n nodes. Show that h...
1. a) Suppose that a binary tree of height h has n nodes. Show that h ≥ log2 (n+2) - 1. b) Using the formula in part (a) find the minimum height if a binary tree with 1000 nodes. c) What is the maximum possible height of a binary tree with 1000 nodes?
(Algorithm) A binary tree has a height of h=4. What is the number of nodes of...
(Algorithm) A binary tree has a height of h=4. What is the number of nodes of this binary tree if the tree is: a) A full binary tree b) A complete binary tree
Suppose a binary tree stores integers. Write efficient methods (and give their Big-Oh running times) that...
Suppose a binary tree stores integers. Write efficient methods (and give their Big-Oh running times) that take a reference to a binary tree root T and compute a. the number of nodes with two children that contain the same value **JAVA**
‏What is the output of the Euler tour in the normal binary search tree if the...
‏What is the output of the Euler tour in the normal binary search tree if the key insert order is 5 , 2 , 8 , 5 , 9 , 5 , 1 , 3 , 4 , 2 , 8 ? All keys equal to the node should be the right subtree of that node. ____________________________________________________________ ‏Construct the binary max - heap for the keys given below. Once all the keys are inserted, perform the remove maximum operation, and...
Let T be a complete binary tree such that node v stores the entry (p(v), 0),...
Let T be a complete binary tree such that node v stores the entry (p(v), 0), where p(v) is the level number of v. Is tree T a heap? Why or why not? I know that a complete binary tree is a heap, but shouldn't we also take into consideration the values that it is storing into the tree: (p(v), 0)? The heap tree could be either a min-heap or max-heap. If we order the the value based of p(v)...
The one missing piece was inserting into a binary search tree; we'll take care of that...
The one missing piece was inserting into a binary search tree; we'll take care of that today and write the insert function, as well as a height function. Both functions will be implemented in the "bst.h" header file, and tested using a provided main program in "main.cpp". Step one is to implement the insert function --- go ahead and modify "bst.h", adding the necessary code to (1) allocate a new node, and (b) link it into the tree. Once you...
[15 pts.] Consider a version of a binary search tree (BST) for sorted maps with integer...
[15 pts.] Consider a version of a binary search tree (BST) for sorted maps with integer keys that stores additional information as data members of each node w of the tree to account for the smallest and largest integer keys in the subtree rooted at w. Suppose that we can access this information using w.min, for the smallest integer key, and w.max, for the largest. Algorithm 4 provides the pseudocode for the constructor of a node in a binary tree...
import java.util.ArrayList; /* Rules:         1. Allow Tester to iterate through all nodes using the...
import java.util.ArrayList; /* Rules:         1. Allow Tester to iterate through all nodes using the in-order traversal as the default.             This means, in Tester the following code should work for an instance of this class             called bst that is storing Student objects for the data:                 BinarySearchTree_Lab08<String> bst = new BinarySearchTree_Lab08<String>();                 bst.add("Man");       bst.add("Soda");   bst.add("Flag");                 bst.add("Home");   bst.add("Today");   bst.add("Jack");                ...
Compute each of the following probabilities. Label each problem clearly and show all your work. Use...
Compute each of the following probabilities. Label each problem clearly and show all your work. Use the numbers you computed in earlier parts of the project based on the class data set. Problem 1: Suppose all of the Skittles in the class data set are combined into one large bowl and you are going to randomly select one Skittle. (a) What is the probability that you select a green Skittle? (4 points) (b) What is the probability that you select...
StudentNO Gender Height in inchese 1 Female 63 2 Female 64.0 3 Male 67.0 4 Female...
StudentNO Gender Height in inchese 1 Female 63 2 Female 64.0 3 Male 67.0 4 Female 59 5 Male 60 6 Female 61 7 Female 62 8 Female 63 9 Female 63 10 Female 64 11 Male 64 12 Female 65 13 Female 65 14 Female 65 15 Female 65 16 Female 66 17 Female 66 18 Male 67 19 Male 67 20 Male 67 21 Female 67 22 Male 67 23 Male 67 24 Female 67.5 25 Male 68...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT