[SOLVED] Assignment 6 – Graphs and Trees

25.00 $

Category:

Description

5/5 - (6 votes)

Write pseudo-code not Java for problems requiring code. You are responsible for the appropriate level of detail.

Write pseudo-code not Java for problems requiring code. You are responsible for the appropriate level of detail. For the questions asking for justification, please provide a detailed mathematically oriented discussion. A proof is not required.

  1. How many ancestors does a node at level n in a binary tree have? Provide justification.
  2. Prove that a strictly binary tree (regular binary tree) with n leaves contains 2n-1 nodes. Provide justification.
  3. Explain in detail that if m pointer fields are set aside in each node of a general m-ary tree to point to a maximum of m child nodes, and if the number of nodes in the tree is n, the number of null child pointer fields is n*(m-1)+1.
  4. Implement maketree, setleft, and setright for right in-threaded binary trees using the sequential array representation.
  5. Implement inorder traversal for the right in-thread tree in the previous problem.
  6. Define the Fibonacci binary tree of order n as follows: If n=0 or n=1, the tree consists of a single node. If n>1, the tree consists of a root, with the Fibonacci tree of order n-1 as the left subtree and the Fibonacci tree of order n-2 as the right subtree. Write a method that builds a

Fibonacci binary tree of order n and returns a pointer to it.

  1. Answer the following questions about Fibonacci binary tree defined in the previous problem.
    1. Is such a tree strictly binary?
    2. What is the number of leaves in the Fibonacci tree of order n?
    3. What is the depth of the Fibonacci tree of order n?