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 17, Problem 3P
(a)
Program Plan Intro
To explain the rebuild the sub-tree rooted at node x so that it becomes 1/2-balanced.
(b)
Program Plan Intro
To explain performing a search in an n-node
(c)
Program Plan Intro
To argue that any binary tree has nonnegative potential and that a 1/2 balanced tree has potential 0.
(d)
Program Plan Intro
To explain the value of c in terms of
(e)
Program Plan Intro
To show that inserting a node into or deleting a node from an n -node
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
2. Show the B+‐tree of order three (namely each node has a maximum of three keys/descendents) that result from loading the following sets of keys in order: a. M, I, T b. M, I, T, Q, L, H, R, E, K c. M, I, T, Q, L, H, R, E, K, P d. M, I, T, Q, L, H, R, E, K, P, C, A
Given 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…
2. We are given a complete binary tree with height h and n nodes. The link between a node and its left child is labeled as 0 and the link between a node and its right child is labeled as 1. A path from the root to each external node at the last level can be labeled by an h-tuple (X1, X2, ..., xh) of 1s and Os that lie on its links. See the following example:
0
0
1
1
0
0
1
0
(0,0,0)
(0,1,1)
Knowledge Booster
Similar questions
- Consider the Binary Search Tree method DepthEqual(T) that outputs all node values in a binary search tree T such that the value stored in the node is equal to the depth of the node in the tree. The values can be any integer, including negative numbers. Show pseudocode for an efficient implementation of DepthEqual(T). Hint: For a node n at depth d, whose value is v. if d >= v. then there is no need to search n's left subtreearrow_forwardLet 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_forwardForm a B-tree with t = 4 by inserting in order nodes with the following keys: I,W,A,N,T,T,O,P,A,S,S,T,H,I,S,T,E,S,T, Draw the B-tree obtained after each improvement.arrow_forward
- 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.}arrow_forwardLet T1, T2 be 2-3-4 trees and let x be a key [in neither T1, T2], such that for each pair of keys x1 ∈ T1 and x2 ∈ T2, we have x1 < x < x2. Thus, every key in T1 is smaller than every key in T2. Devise an algorithm that constructs the union of x with these two trees. Of course, the trees T1, T2 may be of different height, and the result must be a valid 2-3-4 tree. Your algorithm should run in O(1 + |h(T1) − h(T2)|).arrow_forwardLet 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_forward
- Consider a complete binary tree with 7 nodes. Let A denote the set of first 3 elements obtained by performing Breadth-First Search (BFS) starting from the root. Let B denote the set of first 3 elements obtained by performing Depth-First Search (DFS) starting from the root. The value of |A - B| isarrow_forwardSuppose T is a binary tree with 17 nodes. What is the minimum possible depth of T? 1 3 4 2 A binary tree of N nodes has _______. Log2 N levels N / 2 levels Log10 N levels N x 2 levels The difference between a binary tree and a binary search tree is that : in binary search tree nodes are inserted based on the values they contain none of these in binary tree nodes are inserted based on the values they contain a binary search tree has two children per node whereas a binary tree can have none, one, or two children per node What is the best code for the following procedure: AddStudent(studentName):add a new student to an array of alphabetically ordered names . Hint: We must shift some students. size contains the number of students in the array AddStudent(studentName){ int i ; for( i=0; i< size-1; i++){ if(arr[i].compareTo( studentName)>0) break; for(int j= size-1 ; j >i…arrow_forwardDraw the portion of the state space tree generated by LCBB for the following instances. n = 4, m = 15, (P₁, ..., P) = (10, 10, 12, 18) (w₁,..... W 4) = (2, 4, 6, 9).arrow_forward
- Having read the definition of trees, which of the following graphs are trees? Why? Draw each graph to support your answer. Discuss why you think your answer satisfies the tree definition. Upload your preparations on this link.a. G=(V,E)G=(V,E) with V={a,b,c,d,e}V={a,b,c,d,e} and E={{a,b},{a,e},{b,c},{c,d},{d,e}}E={{a,b},{a,e},{b,c},{c,d},{d,e}}b. G=(V,E)G=(V,E) with V={a,b,c,d,e}V={a,b,c,d,e} and E={{a,b},{b,c},{c,d},{d,e}}E={{a,b},{b,c},{c,d},{d,e}}c. G=(V,E)G=(V,E) with V={a,b,c,d,e}V={a,b,c,d,e} and E={{a,b},{a,c},{a,d},{a,e}}E={{a,b},{a,c},{a,d},{a,e}}d. G=(V,E)G=(V,E) with V={a,b,c,d,e}V={a,b,c,d,e} and E={{a,b},{a,c},{d,e}}arrow_forwardProve that any binary tree of height h (where the empty tree is height 0, and a tree witha single node is height 1) has between h and 2h − 1 nodes, inclusive. A binary tree is onein which every node has at most three edges (at most one to the ’parent’ and two to the’children.’)arrow_forward1.Suppose that we first insert an element x into a binary search tree that does not already contain x. Suppose that we then immediately delete x from the tree. Will the new tree be identical to the original one? If yes, please justify your answers with no more that 3 sentences. If no, please give a counterexample. You may draw pictures if need 2. Draw pictures to show how to construct a red-black tree by inserting the keys in the following sequence into an initially empty red-black tree: 8, 4,10, 9, 5, 17. Show each steps. Please use a double edge indicates a red pointer and single edge indicates a black pointer.arrow_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