if number of nodes examined when searching a key is K, then number of nodes examined when inserting the key is K. Answer: K
Suppose a BST is constructed by repeatedly inserting distinct keys into the tree. If the number...
Suppose a bst is constructed by repeatedly inserting distinct keys into the tree. Argue that the number of nodes examined when searching for a key is equal to one more than the number examined when inserting that key. Prove or disprove: deleting keys a and y from a bst is commutative. In other words, it does not matter which order the keys are deleted. The final trees will be identical. If true, provide a proof. If false, provide a counterexample....
4. Suppose a B+ tree with 4 levels having exactly 7 keys in each node. There is a record for each key 1, 2, . . . , k ? 1, k where k is the number of data records. How many nodes should be examined to find records with keys in the range [82, 113]?
package hw3; import java.util.LinkedList; /* *********************************************************************** * A simple BST with int keys and no values * * Complete each function below. * Write each function as a separate recursive definition (do not use more than one helper per function). * Depth of root==0. * Height of leaf==0. * Size of empty tree==0. * Height of empty tree=-1. * * TODO: complete the functions in this file. * DO NOT change the Node class. * DO NOT change the name...
Let TB and T2-3 be, respectively, a classical binary search tree and a 2-3 tree constructed for the same list of keys inserted in the corresponding trees in the same order. True or false: Searching for the same key in T2-3 always takes fewer or the same number of key comparisons as searching in Tg?
8. Given the BST below, show the BST that would result after inserting the key of value 180 if splaying is performed starting at the node that was inserted. 100 50 150 40 60 200 30 9. A nice property of splay trees is that each of Find, Insert and Delete takes O(logn) time. TrueFalse? 10. The keys of value N, N-1, N-2... 4, 3, 2, 1 are inserted in this order in a splay tree. What is the final...
Suppose you started with an empty binary search tree. We've seen previously that inserting the keys 1, 2, 3, 4, 5, 6, 7 (in that order) would lead to a binary search tree whose shape we called degenerate. Propose a second ordering of the same keys that would also lead to a degenerate-shaped binary search tree. If possible, propose a third ordering of the same keys that would also lead to a degenerate-shaped binary search tree. If there are no...
In general, assuming a balanced BST with n nodes (A balanced binary tree has roughly the same number of nodes in the left and right subtrees of the root), what is the maximum number of operations required to search for a key? Please notice that the tree in this exercise is not balanced. Trace the algorithm for creating a parse tree for the expression (((4 x 8)/6)–3 Please help me understand :(
Please answer the following questions. Thanks!
1. A BST is created (it is initially empty)
where the key associated with the data in each node is an integer.
Elements are added to the BST with these keys in this order: 5, 4,
8, 7, 6, 9, 3, 2, 1. (a) Draw the resulting BST.
(b) What is the height of the tree?
2. Continuing, assume the keys of Exercise 5.6
are integers which are appened to a linked list of...
help
2. Do the following problems: Create a binary search tree (BST), with the following words inserted: Int, Char, Return, Break, Float, While, Short, Sort, Double, For, Continue. a. b. Insert the following words into the BST built in (a): Tree, Table, Binary, Network, Visit, Seekk, Traversal c. Where is the minimum key value in a BST? (Give a concrete example) d. Where is the maximum key value in a BST? (Give a concrete example) e. How many comparisons are...
1.(10 pts) Contrast a heap with a binary search tree by inserting the numbers 60, 30, 40, 50, 20, 10 first in a BST and then in a min-heap. Draw the resulting BST on the left and the heap on the right. You may draw any valid BST or Heap that contain the provided values 2. (5 pts) In section 11.1, the book mentions that heaps are **complete** binary trees, what does that mean? Demonstrate by drawing an example of...