Menu

[Solved]1 Given Size Perfect Binary Search Tree N N Form N 2d 1 1 D 0 Key K Within Tree Devise Way Q37277266

Problem Description A perfect binary tree is a binary tree in which every internal node has exactly two children and all theTree size n = 31 Key Type = LEFT Depth = 4 Height 0 Parent- 2 Left - (leaf) Right -- (leaf) Tree size n- 31 Key = 16 Type = R

1. Given the size of a perfect binary search tree, n (with nbeing of the form n = 2d+1 − 1 for some d ≥ 0) and a key k withinthat tree devise a way to compute the following properties of thenode containing k. This could be an efficient algorithm or a seriesof formulas (in terms of n and/or d).

(a) 5 points What is the depth and the height of the nodecontaining k Recall that the depth of a node is the length of thepath from the root to k and the height of a node is the length ofthe longest path from k to any (descendant) leaf.

(b) 5 points What is the key of k’s parent

(c) 5 points Is the node containing k a left child or a rightchild of its parent (the only exception to this is when k is theroot in which case it has no parent)?

(d) 5 points What is the key of k’s left child

(e) 5 points What is the key of k’s right child

Problem Description A perfect binary tree is a binary tree in which every internal node has exactly two children and all the leaves are at the same level. This means that the tree is full at every level up to its deepest level, d (the depth) A perfect binary search tree contains keys 1,2,…,2+1 organized into a perfect tree structure. An example of a perfect binary search tree of depth d-4 is given in Figure 1 16 24 12 20 28 10 14 18 26 30 1 3)(5)(7)(9)(11 )( 13 15 ) 17)( 19 21 )( 23 )( 25 )( 27 )(29) 31 Figure 1: A perfect binary search tree of depth d = 4 with n = 2d+1-1 = 31 sequential Now consider a very large perfect binary search tree. So large that it would be infeasible to construct it. For example, even a “small” depth of d-300 would have more nodes than atoms in the known universe! However, can we can still work “locally” with the tree without explicitly building it? Because of the highly regular structure of such a tree, there is a lot that we can feasibly compute. 1. Given the size of a perfect binary search tree, n (with n being of the form n-2+1-1 for some d 2 0) and a key k within that tree devise a way to compute the following properties of the node containing k. This could be an efficient algorithm or a series of formulas (in terms of n and/or d) (a) 5 points What is the depth and the height of the node containing k Recall that the depth of a node is the length of the path from the root to k and the height of a node is the length of the longest path from k to any (descendant) leaf b)5 points What is the key of k’s parent (c)5 points Is the node containing k a left child or a right child of its parent (the only exception to this is when k is the root in which case it has no parent)? (d) 5 points What is the key of k’s left child (e) 5 points What is the key of k’s right child Tree size n = 31 Key Type = LEFT Depth = 4 Height 0 Parent- 2 Left – (leaf) Right — (leaf) Tree size n- 31 Key = 16 Type = ROOT Depth-0 Height 4 Parent – – (root) Left 8 Right 24 Tree size n- 31 Key = 24 Type = RIGHT Depth = 1 Height 3 Parent 16 Left 20 Right 28 Tree size n- 31 Key = 31 Type = RIGHT Depth = 4 Height 0 Parent – 30 Left – (leaf) Right – – (leaf,) Show transcribed image text Problem Description A perfect binary tree is a binary tree in which every internal node has exactly two children and all the leaves are at the same level. This means that the tree is full at every level up to its deepest level, d (the depth) A perfect binary search tree contains keys 1,2,…,2+1 organized into a perfect tree structure. An example of a perfect binary search tree of depth d-4 is given in Figure 1 16 24 12 20 28 10 14 18 26 30 1 3)(5)(7)(9)(11 )( 13 15 ) 17)( 19 21 )( 23 )( 25 )( 27 )(29) 31 Figure 1: A perfect binary search tree of depth d = 4 with n = 2d+1-1 = 31 sequential Now consider a very large perfect binary search tree. So large that it would be infeasible to construct it. For example, even a “small” depth of d-300 would have more nodes than atoms in the known universe! However, can we can still work “locally” with the tree without explicitly building it? Because of the highly regular structure of such a tree, there is a lot that we can feasibly compute. 1. Given the size of a perfect binary search tree, n (with n being of the form n-2+1-1 for some d 2 0) and a key k within that tree devise a way to compute the following properties of the node containing k. This could be an efficient algorithm or a series of formulas (in terms of n and/or d) (a) 5 points What is the depth and the height of the node containing k Recall that the depth of a node is the length of the path from the root to k and the height of a node is the length of the longest path from k to any (descendant) leaf b)5 points What is the key of k’s parent (c)5 points Is the node containing k a left child or a right child of its parent (the only exception to this is when k is the root in which case it has no parent)? (d) 5 points What is the key of k’s left child (e) 5 points What is the key of k’s right child
Tree size n = 31 Key Type = LEFT Depth = 4 Height 0 Parent- 2 Left – (leaf) Right — (leaf) Tree size n- 31 Key = 16 Type = ROOT Depth-0 Height 4 Parent – – (root) Left 8 Right 24 Tree size n- 31 Key = 24 Type = RIGHT Depth = 1 Height 3 Parent 16 Left 20 Right 28 Tree size n- 31 Key = 31 Type = RIGHT Depth = 4 Height 0 Parent – 30 Left – (leaf) Right – – (leaf,)

Expert Answer


Answer to 1. Given the size of a perfect binary search tree, n (with n being of the form n = 2d+1 − 1 for some d ≥ 0) and a ke… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *