Sale!

# CH-232-A Problem Sheet #2 Solution

Original price was: \$35.00.Current price is: \$30.00.

Category:

## Description

Problem 2.1: proof by contrapositive (4 points)
Let x and y be real numbers, i.e., x, y ∈ R. If y
3 + yx2 ≤ x
3 + xy2
, then y ≤ x.
Problem 2.2: proof by induction (4 points)
Let n be a natural number with n ≥ 1. Prove that the following holds:
1
2 + 32 + 52 + . . .(2n − 1)2 =
Xn
k=1
(2k − 1)2 =
2n(2n − 1)(2n + 1)
6
Problem 2.3: operator precedence and associativity (haskell) (1+1 = 2 points)
Haskell operators have associativity and precedence. The associativity defines in which order
operators with the same precedence are evaluated while the precedence defines in which order
operators with different precedence levels are evaluated (higher precedence level first).
a) Some operators are neither left nor right associative. What happens if such operators appear
multiple times in an expression (without additional parenthesis defining the evaluation order)?
Provide an example and an explanation.
b) Haskell has a very special operator \$. What is the precedence and associativity of this operator? Write the following prefix expression
(^) 2 \$ (*) 5 \$ (+) 2 3
in infix notation without the \$ operator, using parenthesis where necessary.