(e) Consider an initially empty max-heap, where the following keys are to be inserted one at a time: 11, 19, 23, 12, 13, 17, 13, 14, 18, and 33. Draw the tree that results after building this max-heap.
(f) Is it possible to find the maximum in a min-heap in O(log n) time? Justify.
Important Notes:
• For part (e) of this problem, you must draw the min (or max) heaps using the appropriate graphics tools at your convenience.
(e) Consider an initially empty max-heap, where the following keys are to be inserted one at...
5. Heap, 5pts] The following elements are inserted into an empty Max-Heap in the fol- la-FHea lowing order: 2, 3. 1, 4, 6. 12, 15, 22, 11, 5 Draw the resulting heap (use the logical (tree) representation)
c++ *construct (draw) a Max Heap when the following keys are inserted in the given order: 5, 10, 4, 3, 1, 15, 11, 12, 20, 19, 2 *What is the index of the right child of key 20? *Draw the max Heap after performing removeMax()
In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the element of the heap with the smallest key is the root of the binary tree. On the other hand, a max-heap has as root the element with the biggest key, and the relationship between the keys of a node and its parent is reversed of that of a min-heap. We also discussed an array-based implementation of heaps. In this assignment, your task is to...
NOTE: Completing the Third Chart is the most important. This is one question with three parts. (4 pts) Is the following array-based tree a min-heap or a max-heap or not a heap at all? 85 91 S8 95 100 92 a. Min-heap b. Max-heap c. Not a heap 5 pts) Turn the following array-based binary tree into a max-heap. Show your work step by step. (You will not need all the columns) 34 7 12 47 19 5 pts) Show...
Using C++, data structures, C++ STL, inputs and expected outputs are shown below. Max Heap Heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either > (in a max heap) or s (in a min heap) the key of C. The node at the "top" of the heap (with no parents) is called the root node. In binary-tree based heap, it...
5. A three-heap with n elements can be stored in an array A, where A[O] contains the root of the tree. a) Draw the three-heap that results from inserting 5, 2, 8, 3, 6, 4, 9, 7, 1 in that order into an initially empty three-heap. You do not need to show the array representation of the heap. You are only required to show the final tree, although if you draw intermediate trees. b) Assuming that elements are placed in...
Starting with an empty binary search tree, insert each of the following keys and rotate it to the root in the specified order: 6 1 18 7 15 Starting with an empty red-black binary search tree, insert the following keys in order:: 12 5 23 9 19 2 21 18 7 Show the tree immediately after you insert each key, and after each time you deal with one of the book's cases 1, 2, or 3 (that is, if dealing with one case leads to another, show the additional case as a...
[12] 3. a) Draw the binary min-heap after inserting the following values, one after another. 21, 13, 12, 25, 4, 20, 16, 1, 11 You must show each step of building the heap and eventually the final tree. Please, put your final tree inside a box so that it can be easily understood among other intermediate trees. b) A 4-ary max heap is like a binary max heap, but instead of 2 children, nodes have 4 children. A 4-ary heap...
7. Suppose the same set of 31 values are inserted into two separate initially empty Binary Search Trees (BSTS). What is the maximum possible difference in height between the two trees? Answer 8. Which of the following is the most correct and relevant reason radix sort is not used for all sorting applications even though it can have a faster running time than comparison-based sorts? O Not all sorting applications Involve numerical data Not all sorting applications have bounded key...