mcar (n:ns) = n
mcdr (n:ns) = ns
mcons m n = [m] ++ n
41 17 29 53 3 11 23 31 47 59 73 89 ✓ ✓ / 2 5 13 19 37 43 61 71 83 97 (1) Consider the above binary tree, which is represented as a list that adheres to the property [value, left, right], where value is an integer (further a prime number), and left and right are lists ([value, left, right] is a node in the binary tree). Provide a list that describes this structure. Given this binary tree structure, use our Haskell functions mcar and mcdr to access subtrees and elements of the list. (2) How can we access the left child root node? (3) How can we access the right child of the root node? (4) Provide applications of mcar and mcdr to access six values and/or subtree of the structure? You are free to choose which ones to access.
41 17 29 53 3 11 23 31 47 59 73 89 ✓ ✓ / 2 5 13 19 37 43 61 71 83 97 (1) Consider the above binary tree, which is repres
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
41 17 29 53 3 11 23 31 47 59 73 89 ✓ ✓ / 2 5 13 19 37 43 61 71 83 97 (1) Consider the above binary tree, which is repres
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!