Question: Binary Search Trees: Programming One of the data structures we studied is binary search trees. A simple implementation of node for a binary tree is

Binary Search Trees: Programming One of the data structures we studied is binary search trees. A simple implementation of node for a binary tree is shown below for reference. private class Node { public final Key key; public final Value val; public Node left, right; public int N; public Node(Key key, Value val, int N) { this.key = key; this.val = this.N = N; } } val; Implement the recursive method public static boolean equalTrees(Node root1, Node root2) that takes in the roots of two trees and returns true if each respective node in trees is the same. Comparison is done on keys. For example a tree with root 10, left child 5, and right child 15 would not be equal to a tree with root 10, left child 5, and right child 23. It would also not equal the tree with root 10, left child 5, and no right child. (This method basically works as a deep .equals() operation for trees.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
