Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 12.2, Problem 4E
Program Plan Intro
To give a smallest possible counterexample to the professor’s claim.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
We say that a binary search tree T1 can be right-converted to binary search tree T2 if it is possible to obtain T2 from T1 via a series of right rotations. Please draw diagram and Give an example of two trees T1 and T2 such that T1 cannot be right-converted to T2. Explain your answer.
A binary tree is \emph{full} if every non-leaf node has exactly two children. For context, recall that we saw in lecture that a binary tree of height $h$ can have at most $2^{h+1}-1$ nodes and at most $2^h$ leaves, and that it achieves these maxima when it is \emph{complete}, meaning that it is full and all leaves are at the same distance from the root. Find $\nu(h)$, the \emph{minimum} number of leaves that a full binary tree of height $h$ can have, and prove your answer using ordinary induction on $h$. Note that tree of height of 0 is a single (leaf) node. \textit{Hint 1: try a few simple cases ($h = 0, 1, 2, 3, \dots$) and see if you can guess what $\nu(h)$ is.}
Consider a weight balanced tree such that, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (number of nodes on the path from the root to the farthest leaf) of such a tree on k nodes can be described asa) log2 nb) log4/3 nc) log3 nd) log3/2 n
Chapter 12 Solutions
Introduction to Algorithms
Ch. 12.1 - Prob. 1ECh. 12.1 - Prob. 2ECh. 12.1 - Prob. 3ECh. 12.1 - Prob. 4ECh. 12.1 - Prob. 5ECh. 12.2 - Prob. 1ECh. 12.2 - Prob. 2ECh. 12.2 - Prob. 3ECh. 12.2 - Prob. 4ECh. 12.2 - Prob. 5E
Ch. 12.2 - Prob. 6ECh. 12.2 - Prob. 7ECh. 12.2 - Prob. 8ECh. 12.2 - Prob. 9ECh. 12.3 - Prob. 1ECh. 12.3 - Prob. 2ECh. 12.3 - Prob. 3ECh. 12.3 - Prob. 4ECh. 12.3 - Prob. 5ECh. 12.3 - Prob. 6ECh. 12.4 - Prob. 1ECh. 12.4 - Prob. 2ECh. 12.4 - Prob. 3ECh. 12.4 - Prob. 4ECh. 12.4 - Prob. 5ECh. 12 - Prob. 1PCh. 12 - Prob. 2PCh. 12 - Prob. 3PCh. 12 - Prob. 4P
Knowledge Booster
Similar questions
- Let S : S --> {true, false} be a function that inputs a full binary search tree and outputs either true or false, defined as follows. B. If X is a binary search tree consisting only of a single vertex, then S(X ) = true if this vertex equals pork and S(X ) = false otherwise. R. If X is a binary tree with root v, left subtree Xl and right subtree Xr , then S(X ) = true if v equals pork. Otherwise, if v < pork, then S(X ) = S(Xr ). If v > pork, then S(X ) = S(Xl ).arrow_forwardGiven a set of 10 letters { I, D, S, A, E, T, C, G, M, W }, answer the following: a) With the given letters above, we can construct a binary search tree (based on alphabetical ordering) and the sequence < C, D, A, G, M, I, W, T, S, E > is obtained by post-order traversing this tree. Construct and draw such a tree. NO steps of construction required.b) The letter S is first removed from the binary search tree determined above, followed by inserting a new letter R. Draw the updated binary search tree after removal and insertion. Choose the logical predecessor (not successor) of the removing node if necessary c) Determine and list the sequence of elements obtained by pre-order traversing the updated binary search tree after removal and insertion above. No steps required. d) Suppose we are given the first six elements < I, D, S, A, E, T > and their frequencies of occurrence < 5, 6, 2, 4, 5, 2 >, construct and draw the Huffman Tree based on these elements above and their…arrow_forwardConsider a binary search tree (BST) whose elements are the name of animals. Starting with an empty BST, show the effect of successively adding the following elements: cow, fox, bat, ant, lion, cat, goat, dog,and pig. Show the effect of successively deleting fox, cow,and bat from the resulting BST and Traverse the original BST in pre-order, in-orderand post-order.arrow_forward
- D) Draw a binary tree whose inorder traverse is T , W , B , P , Y , R , M , X , L , K , S , A and preorder traverse is R , T , P , W , B , Y , K , M , L , X , S , Aarrow_forwardImplement a function to verify if a binary tree is balanced. A balanced tree, for the purposes of this question, is one in which the heights of the two subtrees of any node never differ by more than one.arrow_forwardDraw the binary search tree that would result if the given elements were added to an empty binary search tree in the given order. Use paint to draw. a. Lisa, Bart, marge, maggie, flanders, smithers, miljouse b. 12,34,1,5,-5,6,19,45,2,-7,47arrow_forward
- Let T be a binary search tree whose keys are all distinct. Suppose T is created by inserting each key into the growing tree. Let x be a leaf node and y be its parent node. Show that if x is the right child of y, then y.key is the largest key in T smaller than x.key. (Hint: Show that the assumption that there is another node z whose key satisfies y.key < z.key < x.key will lead to a contradiction.)arrow_forwardComputer Science Consider a left-child, right-sibling tree T containing n nodes, in which each node stores, among other information, a real number >0, called the node’s score. Find a subset S of all nodes such that the sum of the scores of nodes in S is maximized subject to the constraint that a node and its child cannot both be in S. 1. In C++, write a function to solve the max sum for the nodes with the conditions given. 2. Analyze the running timearrow_forwardConsider a binary search tree (BST) whose elements are the integer values: Starting with an empty BST, show the effect of successively adding the following elements: 15, 78, 10, 5, 12, 82, 60, 68, 11 and 65. Show the effect of successively deleting 10, 78, and 15 from the resulting BST. Traverse the original BST in pre-order and post-order.arrow_forward
- Consider the Fibonacci sequence F(0)=0, F(1)=1 and F(i)=F(i-1)+F(i-2) for i > 1. For the sake of this exercise we define the height of a tree as the maximum number of vertices of a root-to-leaf path. In particular, the height of the empty tree is zero, and the height of a tree with a single vertex is one. Prove that the number of nodes of an AVL tree of height h is at least F(h) and this inequality is tight only for two values of h.arrow_forwardDraw the binary search tree if the in-order traversal of that binary search tree are given as below: In-order traversal: 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 19, 20arrow_forwardRemember, in our definition, the height of a binary tree means maximum number of nodes from the root to a leaf. a) In a perfect binary tree of size n, what is the tree's exact height? Justify your answer. b) In a degenerate binary tree of size n, what is the tree's exact height? Justify your answer. c) What is the maximum height for a balanced binary tree of size 7? Justify your answerarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education