Starting from:

$25

ICS - Sheet 2 -Solved

Introduction to Computer Science

Problem 2.1: proof by contrapositive
(4 points)
Let x and y be real numbers, i.e., x,y ∈R. If y3 + yx2 ≤ x3+ 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:

 

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.

More products