CS 5302 Data Structures and Algorithm Tutorial 5 Tree Written Exercise 1. Give an O(n) algorithm for computing the depth of all the nodes of a tree T, where n is the number of nodes of T. 2. For a tree T, let NI denote the number of internal nodes, and let NE denote the number of its external nodes. Show that if every internal node in T has exactly 3 children, then NE = 2NI + 1. Programming Exercise 3 Design and implement two ADT for binary tree respectively with (a) linked structure, and (b) array based representation. Your ADT should support the methods listed below. Some source codes can be found in pages 283-287. Analyze the running time of each method. addRoot(e) Create and return a new node r storing element e and make r the root. An error occurs if the tree is not empty. insertLeft(v,e) Create and return a new node w storing element e, and w as the left child of v and return w. An error occurs if v already has a left child. insertRight(v,e) Create and return a new node z storing element e, add z as the right child of v and return z. An error occurs if v already has a right child preorderTraverse() Perform preorder traversal of the binary tree.