[Solved] CSCE314 Homework 3-Problem set

$25

File Name: CSCE314_Homework_3-Problem_set.zip
File Size: 282.6 KB

SKU: [Solved] CSCE314 Homework 3-Problem set Category: Tag:
5/5 - (1 vote)

Below, the exercise problems are from the Haskell Textbook: Programming in Haskell, 2nd Ed., by Graham Hutton. Some problems are modified (with additional requirements) by the instructor. Please read corresponding textbook chapters and the problem statements carefully, paying attention to the requirements. There may be significant penalties for not fulfilling such requirements.

Keep the name and type of each function exactly the same as given in the problem statement and the skeleton code. Also, do not remove or modify the test list or the main function. If you remove or modify those, then you will be penalized for that.

Problem 1. Put your full name, UIN, and acknowledgements of any help received in the head comment in your .hs file for this assignment.

Problem 2. Chapter 8, Exercise 1. (The function definition for mult is given in appendix A.) Carefully study the recursive type of natural numbers in Section 8.4. Using the definitions of the recursive data type Nat, mult and add, show how 22 = 4 proceeds, in the same way as showing how 2 + 1 = 3 proceeds given in Section 8.4 (page 97).

Problem 3. [Make sure you read Chapter 16 before attempting this problem.] Chapter 16. Exercise 6, page 247. This problem has two parts. Given the following data type

data Tree = Leaf Int | Node Tree Tree

  1. Given a tree, function leaves counts the number of leaves in the tree, and function nodes the number of internal nodes in the tree. Define leaves and nodes. The function types are as follows.

leaves :: Tree -> Int nodes :: Tree -> Int

  1. Prove the following property by induction on trees.

leaves t = nodes t + 1

Problem 4. Chapter 8, Exercise 9. Study Section 8.7 carefully before attempting this problem.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCE314 Homework 3-Problem set
$25