Question: full description is already attached. please read all by clicking on the attached document. full description is already there what possibly more information do you
3. (5 pts.) Drawing Trees on a grid. When drawing trees on grid, each node must be assigned an and y-coordinate Edges are then drawn between anode and its children For binary trees, there is a simple and elegant way of assigning nodes their coordinates so that the resulting drawing is nice. For each node, let its coordinate be i the ith node processed by an inorder traversal of the tree let it coordinate be- the depth of win the tree is. The binary tree below is drawn using the said and y-coordinates. For example, has coordinates (12.01, has coordinates (10 while has coordinates (17 ) The above technique though does not generalito arbitrary trees - noder traversas are only meaningful onbinary trees. So we need to design a more flexible orithm But first, let's clarify what it means for and drawing of a tree to be nice For the rest of the problem assume that references to the children of each mode stored in children. The children are the ordered that there is a first child second child, and the children are accessed in the said order. Lastly, assume that every node has an an even number of children, the quadtrees or actrees, etc. Here are the rules Each node is assigned integer - and y-coordinates Two nodes that have the same depth in T are assigned the same coordinate When node has a children, the first children and their subtrees have coordinates smaller than coordinate while the second set of children and their trees have coordinates larger than's coordinate a. (15 pts) For the tree below assign the nodes and coordinates that obey the three rules above. The coordinates should range from 1 to the coordinates should range from 2 to 0 3 pts) Given a tree Twith nodes, design an i me gorithm that assigns each mode and coordinates that obey the three rules above. The coordinates must range from 1 to while the coordinates range from to where is the height of T. Your output should consist of print statements of the form "Draw label at Cr-coordinate, y-coordinate)." Reminder: Every node in the tree has an even number of nodes. The number of children though may vary from node to node leg. one node may have 2 children, another children, etc.) c.0.5 pts.) What extra rule would you sugest for drawing trees where the nodes can have an odd number of children? Why? 3. (5 pts.) Drawing Trees on a grid. When drawing trees on grid, each node must be assigned an and y-coordinate Edges are then drawn between anode and its children For binary trees, there is a simple and elegant way of assigning nodes their coordinates so that the resulting drawing is nice. For each node, let its coordinate be i the ith node processed by an inorder traversal of the tree let it coordinate be- the depth of win the tree is. The binary tree below is drawn using the said and y-coordinates. For example, has coordinates (12.01, has coordinates (10 while has coordinates (17 ) The above technique though does not generalito arbitrary trees - noder traversas are only meaningful onbinary trees. So we need to design a more flexible orithm But first, let's clarify what it means for and drawing of a tree to be nice For the rest of the problem assume that references to the children of each mode stored in children. The children are the ordered that there is a first child second child, and the children are accessed in the said order. Lastly, assume that every node has an an even number of children, the quadtrees or actrees, etc. Here are the rules Each node is assigned integer - and y-coordinates Two nodes that have the same depth in T are assigned the same coordinate When node has a children, the first children and their subtrees have coordinates smaller than coordinate while the second set of children and their trees have coordinates larger than's coordinate a. (15 pts) For the tree below assign the nodes and coordinates that obey the three rules above. The coordinates should range from 1 to the coordinates should range from 2 to 0 3 pts) Given a tree Twith nodes, design an i me gorithm that assigns each mode and coordinates that obey the three rules above. The coordinates must range from 1 to while the coordinates range from to where is the height of T. Your output should consist of print statements of the form "Draw label at Cr-coordinate, y-coordinate)." Reminder: Every node in the tree has an even number of nodes. The number of children though may vary from node to node leg. one node may have 2 children, another children, etc.) c.0.5 pts.) What extra rule would you sugest for drawing trees where the nodes can have an odd number of children? Why
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
