Question: Please solve 3 a, d, and e. B is iv and c is v 3. Wednesday Definition The set of linked lists of natural numbers
Please solve 3 a, d, and e. B is iv and c is v

3. Wednesday Definition The set of linked lists of natural numbers L is defined by: Basis Step: Recursive Step: DEL If I EL and n E N, then (nl) EL Definition The function length: L + N that computes the length of a list is: Basis Step: length: L N length(I) = 0 Recursive Step: Ifle L and n E N, then length((n,1)) = 1+ length(1) Consider this (incomplete) definition: Definition The function increment : defined by: that adds 1 to each element of a linked list is increment: Basis Step: increment(I) Recursive Step: If le Line N increment((n,1)) = 0 = (1+n, increment(1) Consider this incomplete) definition: Definition The function sum: L + N that adds together all the elements of the list is defined by: sum: L N Basis Step: sum(1) = 0 Recursive Step: If le Lin EN sum((n,1)) (a) (You will compute a sample function application and then fill in the blanks for the domain and codomain) Based on the definition, what is the result of increment((4, (2, (7, 1))))? Write your answer directly with no spaces. (b) Which of the following describes the domain and codomain of increment? i. L N ii. L + NXL iii. LXN + L iv. LXN N v. L + L vi. None of the above (c) Assuming we would like sum((5,(6, 1))) to evaluate to 11 and sum((3, (1, (8, [)))) to evaluate to 12, which of the following could be used to fill in the definition of the recursive case of sum? 1+ sum(1) when n 70 i. sum(1) when n = 0 ii. 1+ sum(1) iii. n + increment(1) iv. n + sum(1) v. None of the above (d) Choose only and all of the following statements that are well-defined; that is, they correctly reflect the domains and codomains of the functions and quantifiers, and respect the notational conventions we use in this class. Note that a well-defined statement may be true or false. 10 i. V E L (sum(1)) ii. 31 L (sum(1) A length(1)) iii. V E L (sum( increment(1)) = 10) iv. 31 L (sum( increment(1)) = 10) v. V e LVN E N((n xl) CL) vi. VII E L32 E L (increment(sum(11)) = 12) vii. VI E L (length(increment(1)) length()) (e) Choose only and all of the statements in the previous part that are both well-defined and true. 3. Wednesday Definition The set of linked lists of natural numbers L is defined by: Basis Step: Recursive Step: DEL If I EL and n E N, then (nl) EL Definition The function length: L + N that computes the length of a list is: Basis Step: length: L N length(I) = 0 Recursive Step: Ifle L and n E N, then length((n,1)) = 1+ length(1) Consider this (incomplete) definition: Definition The function increment : defined by: that adds 1 to each element of a linked list is increment: Basis Step: increment(I) Recursive Step: If le Line N increment((n,1)) = 0 = (1+n, increment(1) Consider this incomplete) definition: Definition The function sum: L + N that adds together all the elements of the list is defined by: sum: L N Basis Step: sum(1) = 0 Recursive Step: If le Lin EN sum((n,1)) (a) (You will compute a sample function application and then fill in the blanks for the domain and codomain) Based on the definition, what is the result of increment((4, (2, (7, 1))))? Write your answer directly with no spaces. (b) Which of the following describes the domain and codomain of increment? i. L N ii. L + NXL iii. LXN + L iv. LXN N v. L + L vi. None of the above (c) Assuming we would like sum((5,(6, 1))) to evaluate to 11 and sum((3, (1, (8, [)))) to evaluate to 12, which of the following could be used to fill in the definition of the recursive case of sum? 1+ sum(1) when n 70 i. sum(1) when n = 0 ii. 1+ sum(1) iii. n + increment(1) iv. n + sum(1) v. None of the above (d) Choose only and all of the following statements that are well-defined; that is, they correctly reflect the domains and codomains of the functions and quantifiers, and respect the notational conventions we use in this class. Note that a well-defined statement may be true or false. 10 i. V E L (sum(1)) ii. 31 L (sum(1) A length(1)) iii. V E L (sum( increment(1)) = 10) iv. 31 L (sum( increment(1)) = 10) v. V e LVN E N((n xl) CL) vi. VII E L32 E L (increment(sum(11)) = 12) vii. VI E L (length(increment(1)) length()) (e) Choose only and all of the statements in the previous part that are both well-defined and true
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
