Question

Let T be a binary tree with n nodes and let f() be the level numbering function of the positions of T

f suggests a epteseniatñion of a binary tree Tty in el marabering function f suggests a f an aray-ased wucture A. with the lt of the array We show an etample of an an el ermbering funcion f sugests a represeuani sl Wr show an example of an antay baed rerjesctanisa od a A with the clement an positn pot T stoned at The lene adex fip) of the array We show a ele 12 0 1 23469 10 1 12 13 14 re &.10: Representation of a binary tree by means of an anay of an array-based representation of a binary tree is that a posi- pcan be represented by the single integer fp), and that postion-based net- ach as root, parent, left, and right can be implemented using simple anithmetic persouns oe the mamber f(p). Based on our formula for the level mumbering the ea dhid of p has index 2f(p)+ 1, the right child of p has indes 2fiP)2 and tie parent of p has index tf() 1)/2. We leave the details of a complete amay- one advantage in lsed inplementation as Exercise R-8.14 The space usage of an array based representation depends greatly os the stupe of the trec. Let n be the number of nodes of T, and et fu be the maximam value ol fp over all the nodes of T. The array A requires length NI+ fu, since denents range from Alo! to ALfu]. Note that A may lave a number of empty cels do at refer to existing positions of T. In fact, in the worst case, -1 ㈦estification of which is left as an exercise (R-812). In Section93, we will of binary trees, called heaps for which N. Thas, in spite of the space usage, there are applications for which the array repeesentation r tee is space efficient. Siüll, for general binary trees, the exponential we a class of cve space requirement of this representation is prohibitive. eoou cannot be etticiet of an array representation is that many update operations for beciently supported. For example, removing a pode and promoting ies On time because it is not just the child that moves locations within eray but all descendants of that child


media%2F455%2F455face5-876d-41c6-8731-67

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Let T be a binary tree with n nodes and let f() be the level numbering...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • 6. T or F: There can be two or more nodes in a heap with exactly...

    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...

  • Please address all the questions on the photo. 5. Consider the following binary tree: A B...

    Please address all the questions on the photo. 5. Consider the following binary tree: A B C E F e De G H. K . M NO RO P Q T a. What is the height of the tree? b. What is the height of vertex H? c. Write the preorder traversal representation of the tree. d. Write the array representation of the tree by completing the following table: Right Child Left Child Vertex A C D G H K...

  • Assume the following notation/operations on AVL trees. An empty AVL tree is denoted E. A non-empty AVL tree T has three...

    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...

  • Assume the following notation/operations on AVL trees. An empty AVL tree is denoted E. A non-empty AVL tree T has three...

    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...

  • The INORDER traversal output of a binary tree is U,N,I,V,E,R,S,I,T,Y and the POSTORDER traversal output of the same tree is N,U,V,R,E,T,I,S,I,Y

     a. The INORDER traversal output of a binary tree is U,N,I,V,E,R,S,I,T,Y and the POSTORDER traversal output of the same tree is N,U,V,R,E,T,I,S,I,Y. Construct the tree and determine the output of the PREORDER traversal output.   b. One main difference between a binary search tree (BST) and an AVL (Adelson-Velski and Landis) tree is that an AVL tree has a balance condition, that is, for every node in the AVL tree, the height of the left and right subtrees differ by at most 1....

  • (20 points) Suppose you are given a binary search tree T of n nodes (as discussed...

    (20 points) Suppose you are given a binary search tree T of n nodes (as discussed in class. each node v has v.left, v.right, and v.key). We assume that no two keys in T are equal. Given a value x, the rank operation rank() is to return the rank of x in T, which is defined to be one plus the number of keys of T smaller than 2. For example, if T has 3 keys smaller than r, then...

  • k-d tree Background One generalization of binary trees is the k-d tree, which stores k-dimensional data....

    k-d tree Background One generalization of binary trees is the k-d tree, which stores k-dimensional data. Every internal node of a k-d tree indicates the dimension d and the value v in that dimension that it discriminates by. An internal node has exactly two children, containing data that is less-than-or-equal and data that is greater than v in dimension d. For example, if the node distinguishes on dimension 1, value 107, then the left child is for data with y...

  • You will construct a Huffman tree based on the given frequencies of 26 English alphabets in...

    You will construct a Huffman tree based on the given frequencies of 26 English alphabets in upper case plus the space character. An internal tree node class in HuffmanTree with necessary information is required. • You will not randomly switch left and right children when merger two trees. Instead, you will build a right-heavy tree according to the following strategies to select the right child. (1) The tree that is taller will be the right child, i.e., the height is...

  • #include<iostream> using namespace std; class TNode { public: int val; TNode(){} TNode(int v){val = v;} TNode...

    #include<iostream> using namespace std; class TNode { public: int val; TNode(){} TNode(int v){val = v;} TNode * left; TNode * right; TNode * parent; }; class BTree { public: //constructors and destructor BTree(); BTree(TNode *r);// initialize BTree with the root r. r is the only node. BTree(const BTree & t); // copy constructor BTree(const int *p, const int n);// similar to the copy constructor, but your input is of the array form. // input is given an array that denotes...

  • C++ Binary Search Tree question. I heed help with the level 2 question please, as level...

    C++ Binary Search Tree question. I heed help with the level 2 question please, as level 1 is already completed. I will rate the answer a 100% thumbs up. I really appreciate the help!. Thank you! searching.cpp #include <getopt.h> #include <iostream> #include <sstream> #include <stdlib.h> #include <unistd.h> using namespace std; // global variable for tree operations // use to control tree maintenance operations enum Mode { simple, randomised, avl } mode; // tree type // returns size of tree //...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT