3. Given a tree t, a trace in t is the sequence of nodes on some paths in the tree that is either empty or starts with the root node of t and ends with some (not necessarily leaf) node; let traces t be the set of all the traces in t. For example exactly all the traces of the tree shown in Question 1 (expressed as HASKELL lists) are: [[], [2], [2,5], [2,6], [2,7], [2,6,8], [2,6,9]] You are asked to obtain the traces of a tree (binary or otherwise) using a single function traces for both types. For this purpose implement a type class Traceable that expresses the property of some HASKELL type to have traces, and then make both trees and binary trees instances of Traceable.
3. Given a tree t, a trace in t is the sequence of nodes on some paths in the tree that is either empty or starts with the root node of t and ends with some (not necessarily leaf) node; let traces t be the set of all the traces in t. For example exactly all the traces of the tree shown in Question 1 (expressed as HASKELL lists) are: [[], [2], [2,5], [2,6], [2,7], [2,6,8], [2,6,9]] You are asked to obtain the traces of a tree (binary or otherwise) using a single function traces for both types. For this purpose implement a type class Traceable that expresses the property of some HASKELL type to have traces, and then make both trees and binary trees instances of Traceable.
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps