Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with coding these methods for an AVL /** * Returns the data in the deepest node. If there are more than one node

Please help with coding these methods for an AVL

/** * Returns the data in the deepest node. If there are more than one node * with the same deepest depth, return the right most node with the * deepest depth. * * Must run in O(log n) for all cases * * Example * Tree: * 2 * / \ * 0 3 * \ * 1 * Max Deepest Node: * 1 because it is the deepest node * * Example * Tree: * 2 * / \ * 0 4 * \ / * 1 3 * Max Deepest Node: * 3 because it is the maximum deepest node (1 has the same depth but 3 > 1) * * @return the data in the maximum deepest node or null if the tree is empty */ public T maxDeepestNode() {

}

/** * Returns the data of the deepest common ancestor between two nodes with * the given data. The deepest common ancestor is the lowest node (i.e. * deepest) node that has both data1 and data2 as descendants. * If the data are the same, the deepest common ancestor is simply the node * that contains the data. You may not assume data1 < data2. * (think carefully: should you use value equality or reference equality?). * * Must run in O(log n) for all cases * * Example * Tree: * 2 * / \ * 0 3 * \ * 1 * deepestCommonAncestor(3, 1): 2 * * Example * Tree: * 3 * / \ * 1 4 * / \ * 0 2 * deepestCommonAncestor(0, 2): 1 * * @param data1 the first data * @param data2 the second data * @throws java.lang.IllegalArgumentException if one or more of the data * are null * @throws java.util.NoSuchElementException if one or more of the data are * not in the tree * @return the data of the deepest common ancestor */ public T deepestCommonAncestor(T data1, T data2) {

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

a. What is the purpose of the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago