Write the following Scheme functions in Java: \"repChildren\" - takes in four pa
ID: 3926993 • Letter: W
Question
Write the following Scheme functions in Java:
"repChildren" - takes in four parameters: - a binary tree T - a key value K - a new left child value L - a new right child value R The input tree is a list of the form (root leftchild rightchild), where the root is an integer, and the left and right children are trees. An empty tree is denoted by the empty list, and leaf nodes are designated with an empty list. The tree is not necessarily ordered. Your function returns a list similar to L, but at each occurrance of K, its children are replaced by L and R. For example: (repChildren '(7 (3 () ()) (6 (5 () ()) ()))) should return: (7 (3 () ()) (6 (1 () ()) (2 () ()))) Note that the inserted children need to be inserted as nodes, meaning they must be given left and right children that are empty lists (as shown in the above example).
Explanation / Answer
The BinaryTree class consists of an array of TreeNodes ...
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.