This is an extension to Java Tree structure interview and coding questions — Part 2, and adds functional programming and recursion. Step 1: The Tree interface with get( ) method that returns either a Triple tree or Leaf data.
|
1 2 3 4 5 6 7 |
package com.mycompany.flatten; public interface Tree<T> { abstract Either<T, Triple<Tree<T>>> get(); } |
Step…