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.

icon
Related questions
Question
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.
Transcribed Image Text: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.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer