Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[25 credits] Question 3 Consider the definition of binary trees given in the lectures Tree Induction data Tree a= Nul | Node (Tree a) a
[25 credits] Question 3 Consider the definition of binary trees given in the lectures Tree Induction data Tree a= Nul | Node (Tree a) a (Tree a) and the following three functions: f :: Tree a -> Int fNul =0 f (Node Nul x Nul) = 1 f (Node 1 x r ) = (f 1) + (f r) F1 F2 F3 g :: Tree a -> Int h :: Int ->Tree a -> Int h acc Nul = acc h acc (Node Nu1 x Nui) -acc + 1 h acc (Node l xr h (h acc 1) r H1 H2 H3 Establish, using structural induction, that ft-g t for all trees t of type Tree a. State clearly what property P is being proved by induction, including any quantifiers needed in th Int fNul =0 f (Node Nul x Nul) = 1 f (Node 1 x r ) = (f 1) + (f r) F1 F2 F3 g :: Tree a -> Int h :: Int ->Tree a -> Int h acc Nul = acc h acc (Node Nu1 x Nui) -acc + 1 h acc (Node l xr h (h acc 1) r H1 H2 H3 Establish, using structural induction, that ft-g t for all trees t of type Tree a. State clearly what property P is being proved by induction, including any quantifiers needed in th
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started