Form a recurrence relation for the minimum number of full nodes F(h) in a AVL tree. A node is full if it has exactly two children
In an AVL tree, the balance at every node must be maintained, i.e the absolute difference in the height of the left and the right subtrees can be at most 1.
Let N(h) be the minimum number of nodes in an AVL tree for a given height h.
The base conditions are
a) For h = 0, only 1 node is in the AVL tree; N(0) = 1
b) For h = 1, minimum of 2 nodes are in the AVL tree; N(1) = 2
For a given height h, one subtree is of height h-1 and the other can be at most h-2 after excluding the root node.
Hence N(h) = 1 + N(h-1) + N(h-2), h>= 2; is the recurrence relation.
Python Code Snippet. (For h = 3, the expected answer is 7)
Form a recurrence relation for the minimum number of full nodes F(h) in a AVL tree....
Trees and Heaps 1. Show that the maximum number of nodes in a binary tree of height h is 2h+1 − 1. 2. A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a nonempty binary tree. 3. What is the minimum number of nodes in an AVL tree of height 15? 4. Show the result of inserting 14, 12, 18, 20, 27, 16,...
(b) You are given the AVL Tree in the figure below. Assume that the nodes are sorted in alphabetical order. E J B D K A F L H Draw the resulting BST after node E is removed. To construct the new BST replace node E with an appropriate node from the left subtree of E. Do not rebalance the resulting tree. Label each node in the resulting tree with its balance factor. (e) Now rebalance the tree from the...
Recall from Assignment 2 the definition of a binary tree data structure: either an empty tree, or a node with two children that are trees. Let T(n) denote the number of binary trees with n nodes. For example T(3) 5 because there are five binary trees with three nodes: (a) Using the recursive definition of a binary tree structure, or otherwise, derive a recurrence equation for T(n). (8 marks) A full binary tree is a non-empty binary tree where every...
Assume the following notation/operations on AVL trees. An empty AVL tree is denoted E. A non-empty AVL tree T has three attributes The key T.key is the root node's key. The left child T.left is Ts left subtree, which is an AVL tree (possibly E). The right child T.right is T's right subtree, which is an AVL tree (possibly E). (a) 5 marsl Write a function RANGECOUNT(T, lo, hi) to count the number of nodes in an AVL tree with...
True or false? (a) An insertion in an AVL tree with n nodes requires Θ (log(n)) rotations. (b) A set of numbers are inserted into an empty BST in sorted order and inserted into an empty AVL tree in random order. Listing all elements in sorted order from the BST is O (n), while listing them in sorted order from the AVL tree is O (log(n)). (c) If items are inserted into an empty BST in sorted order, then the...
Assume the following notation/operations on AVL trees. An empty AVL tree is denoted E. A non-empty AVL tree T has three attributes: • The key T.key is the root node’s key. • The left child T.left is T’s left subtree, which is an AVL tree (possibly E). • The right child T.right is T’s right subtree, which is an AVL tree (possibly E). (a) [5 marks] Write a function RangeCount(T, lo, hi) to count the number of nodes in an...
Give an equation to calculate the minimum number of nodes in a complete binary tree of height h. This means that every height 1,..,h-1 is completely full.
(2 points) A full binary tree has a start node, internal nodes, and leaf nodes. The number of leaf nodes of this binary tree is 256. a) What is the height of the tree? b) How many internal nodes are in this tree?
Problem 2 (8 pts): Structural Induction In a binary tree, a full node is a node with two children. Using structural induction, prove that the number of full nodes plus one is equal to the number of leaves in a binary tree (even if the tree itself is not necessarily full, i.e. some nodes may not be full)
6. T or F: There can be two or more nodes in a heap with exactly one child. 7. T or F: A heap can have no nodes with exactly one child. 8. T or F: All heaps are perfect trees. 9. T or F: No heaps are perfect trees. 10. T or F: All heaps are complete trees. 11. T or F: No heaps are complete trees. 12. T or F: A binary tree with one node must be...