{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# sahni2-3 - Data Structures Algorithms Exam 2 Sample 3 75...

This preview shows pages 1–3. Sign up to view the full content.

Data Structures & Algorithms Exam 2 Sample 3, 75 Minutes Notes: 1. Write your name, social security number, and section in which you want your exam returned on each sheet. 2. Begin the answer to each question on a new sheet. 1. [18] The classes MyBinaryTreeNode and MyBinaryTree are given below. Objects of type MyBinaryTree are linked binary trees. public class MyBinaryTreeNode { Object element; BinaryTreeNode leftChild; // left subtree BinaryTreeNode rightChild; // right subtree } public class MyBinaryTree { BinaryTreeNode root; // root node // code you write will come here } You are to write a public method maxHeightDifference() . The invocation x.maxHeightDifference() returns 0 if the binary tree x is empty; otherwise, it returns the maximum difference in the heights of the left and right subtrees of any node in the tree. x.maxHeightDifference() = max y is a node of x {|height(left subtree of y) - height(right subtree of y)|}

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
(a) [16] Write Java code for the public method maxHeightDifference . You may define, implement and create additional methods and variables as needed. You
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

sahni2-3 - Data Structures Algorithms Exam 2 Sample 3 75...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online