Previous sheets

Blatt 1

Start time:
Mi 26 Apr 2017 16:00:42
End time:
Fr 28 Apr 2017 18:00:43

Assignments 2

Haskell Lists (6 P)
Implement the following functions  including their type definitions . Note: If you don't write down type definitions, the compiler will warn about "Top-level binding with no type signature"....
Haskell Type Definitions (6 P)
Write down the type definitions of the following expressions: a)     (True‚'a',[1,2,3]) b)     (['a'],['b'],['b'],['a']) c )  ...
Blatt 2

Start time:
Mi 03 Mai 2017 16:00:40
End time:
So 07 Mai 2017 18:00:40

Assignments 5

Safe tail (3 P)
Write a function "safetail", that does the same thing as the standard "tail" function but also works on empty lists: "safetail" should return an empty list when called with an empty list. Give...
List Comprehensions (3 P)
Implement the following functions using list comprehensions. a)  (1 P) A triple (x,y,z) is called Pythagorean Triple if the equation x^2+y^2=z^2 holds (for x>=1 and x<=y). Write a...
Pattern Matching (3 P)
Implement three functions  and2 ,  or2  and  xor2  that implement the logic operations AND, OR and XOR respectively. You shall only use pattern matching for your...
Currying & Sections (4 P)
a)   (1 P) Given the following function: f :: Fractional a => (a,a) -> a f t = (/) (fst t) (snd t) Write down the curried version of f including its type definition. b)   (1...
Recursion (3 P)
Implement the following functions using recursion. Don't just delegate to standard prelude functions that might do the same thing! a)   (1 P) repl :: Int -> a -> [a] returns a...
Blatt 3

Start time:
Mi 10 Mai 2017 16:00:14
End time:
Fr 12 Mai 2017 18:00:14

Assignments 2

Recursion 2 (4 P)
Implement the following functions using recursion.  a)   (2 P) Implement a function 'ggT' (including its type definition) using guarded equations. ggT shall return the greatest common...
Higher Order Functions (6 P)
a)   (2 P) Implement two variants of a function, named multiplesOf33 and multiplesOf33'. The function should take a list of integers as input and remove all values from the...
Blatt 4

Start time:
Mi 17 Mai 2017 16:00:09
End time:
Mo 22 Mai 2017 18:00:09

Assignments 4

Reiteration: Partial application (1 P)
Please explain "currying" to your teammate. In return, your partner should explain "partial application of functions" to you. These are important concepts in Haskell, that you should understand...
Natural Number Type (3 P)
Given the algebraic data type Nat from the lecture      data Nat = Zero | Succ Nat that represents a natural number. The functions nat2int and int2nat from the lecture might...
Algebraic Data Types (5 P)
a)  (1 P) Write two type declarations 'Year' and 'Day' that should both be aliases for Int. Also define a new data type 'Month' with the following 12 type constructors: Jan, Feb, Mar, Apr,...
Folds (4 P)
a)   (1 P) Implement an alternative version of map (name it map2) using foldr. Also write down the type definition of map2. b)   (1 P) Implement an alternative version of filter (name...
Blatt 5

Start time:
Mi 24 Mai 2017 16:00:16
End time:
Fr 26 Mai 2017 18:00:16

Assignments 2

Function application and composition (3 P)
a) Apply function application and composition to rewrite the following functions. (1 P)     i)  Remove the parentheses by using the $ function.        f...
Maybe (6 P)
You are given a data type 'Person' that is used to encode family relationships and two functions extracting mother or father from a Person (see the test program below)      mother ::...
Blatt 6 (optional)

Start time:
Mi 24 Mai 2017 16:00:49
End time:
Fr 09 Jun 2017 18:00:49

Assignments 3

Binary Tree Type
Given the recursive algebraic data type     data Tree a = Leaf a | Node (Tree a) (Tree a)  deriving Show The 'deriving Show' part makes sure that a Tree can be printed. Note...
Lists as Monads
By now, you should have an impression of the Maybe monad introduced in the lecture. This is by far not the only monad in Haskell, in fact you are already familiar with another important monad:...
Moving in 3 dimensions
Imagine a grid of voxels in three-dimensional space. Each voxel is uniquely identified by its coordinates (x, y, z) where x, y, z are integers. You start somewhere on the grid and move according...
Blatt 7

Start time:
Mi 31 Mai 2017 16:00:13
End time:
Fr 02 Jun 2017 18:00:13

Assignments 2

Divisibility (2 P)
Implement a C++-program that reads numbers from standard input until a 0 is entered. For every input number it should print the following messages to standard output:     - "yes", if...
Collatz (2 P)
Implement a C++-program that reads one initial number from standard input and then generates the Collatz series as follows: Pseudocode:   1   as long as number does not equal 1 do:...
Blatt 8

Start time:
Mi 07 Jun 2017 16:00:36
End time:
Fr 09 Jun 2017 18:00:36

Assignments 4

Datatype limits (2 P)
Experimentally determine the maximum number within the range of short, unsigned short, char and unsigned char and print it (in one line each).
Fibonacci (3 P)
Implement two functions fibonacci1 and fibonacci2 that compute the n-th Fibonacci number. F(0)=0; F(1)=1; F(n+2)=F(n+1)+F(n) Provide an iterative and a recursive implementation. If called...
Reverse (4 P)
Write a program that  - reads integers from standard input (cin)  - stops reading if 0 is entered   - prints all numbers (except the last 0) in reversed order Implement a ...
Mutual recursion (3 P)
Implement two mutual recursive Functions F and M F(0)=1; M(0)=0 F(n)=n-M(F(n-1)), n>0 M(n)=n-F(M(n-1)), n>0
Blatt 9

Start time:
Mi 14 Jun 2017 16:00:35
End time:
Fr 16 Jun 2017 18:00:35

Assignments 2

Pointers (2 P)
Given the C++-program below. Explain in one sentence each, the output of a) to d).
Memory (4 P)
Given the C++-program below.  a)   (4 P) Write down the state of the stack and the heap after each change to either one of them. You can either use prose (not recommended) or...
Blatt 10

Start time:
Mi 21 Jun 2017 16:00:34
End time:
Fr 30 Jun 2017 18:00:35

Assignments 5

Arrays (6 P)
Write a program that  - reads an int 'n' from the console  - makes an array of 'n' ints on the heap  - fills it with n values from the console  - read an int 'r' from the...
Binary Search (3 P)
Implement the function     bool binary_search(const int* begin, const int* end, int key) which should use  binary search  to determine whether a sorted range of integer...
Pointers to Pointers (4 P)
Write a program that processes an 'irregular matrix' of values. Read all values from the console and store everything on the free store (heap). Then compute the result using separate functions and...
Yahtzee (5 P)
Write a program that - reads the number of pips showing on 5 dices from the standard input - prints the maximum score achievable in the game of Yahtzee ('Kniffel' in German, see score list below)...
C Strings (6 P)
Strings in C are "null-terminated" arrays of characters (char). This means that the last element of a C string is a char with value 0 (also represented by '\0') which is used as an end...

Pages: 1 2 >