makecoroutine procedure studied in class in Scheme.
Use makecoroutine to implement the same-leaves? predicate over two
trees.
The function you must write will be called:
(same-leaves? t1 t2)The trees are defined according to the following BNF:
<tree> ::= ()
| (<root> <left-tree> <right-tree>)
<root> ::= <symbol>
The function must return true if the two trees have the same fringe
(ordered list of leaves left-to-right) and false otherwise. The function
must return immediately as the first mismatch is found between two leaves.
Write another version of the same function using streams. You must write a stream-generator function that takes a tree as input and returns the stream of its leaves.
(same-leaves-with-streams? t1 t2) uses: (leaves-generator tree)
Coroutine in Java.
The coroutine constructor must receive as a parameter an instance of a class implementing the Runnable interface (similarly to the Thread class).
Coroutines interact using the resume method.
Use this class to implement a solution to the same-leaves problem in Java.