Linkt to the workspace
A link to my workspace.
Solution to the first assignment
A solution to the first assigment. The solution does not use exception handling.
The second big assignment
Write a simulator of the Game of Life ! Please, send your programs to:
mrp 'apud' pjwstk 'dot' edu 'dot' pl
before 12.06.2016. Here you may find more information about the Game of Life .
mrp 'apud' pjwstk 'dot' edu 'dot' pl
before 12.06.2016. Here you may find more information about the Game of Life .
The first big assignment
Help the monkey escape labyrinth ! Please, send your programs to:
mrp 'apud' pjwstk 'dot' edu 'dot' pl
before 15.05.2016. Here you may find a sample labyrinth .
mrp 'apud' pjwstk 'dot' edu 'dot' pl
before 15.05.2016. Here you may find a sample labyrinth .
Lesson 6: elements of dynamic programming
Exercise - write a function that solves the coin problem. A coin problem consists of a value v and n types of coin denominations of values:
1 = c1 < c1 < ... < cn
(coin 1 is always included, so it is always possible to make change for any amount of money). A solution to the coin problem is the minimum number of coins needed to make the change for the amount v.
1 = c1 < c1 < ... < cn
(coin 1 is always included, so it is always possible to make change for any amount of money). A solution to the coin problem is the minimum number of coins needed to make the change for the amount v.
Lesson 5: playing with arrays 2
Exercise - write implementations of the following functions:
REAL trace(MATRIX matrix, int n); REAL determinant(MATRIX matrix, int n); MATRIX coffactors(MATRIX matrix, int n); MATRIX inverse(MATRIX matrix, int n); |
Lesson 4: playing with arrays
Try to understand the code and complete missing definitions.
Lesson 3: the heap
During the lesson we shall learn how the memory management system works (in C/C++).
Warmup: write a declaration of a function that takes a pointer to "a function that takes double and returns a pointer to double" and returns a pointer to a pointer to "a function that takes int and returns a pointer to a pointer to int".
Exercise: write a function that takes an array of integers and returns the array of the same integers sorted (do not use any external functions); the function should not modify the initial array.
Exercise (*): write a function that takes a system of affine equations and returns a solution of the system (do not use any external functions).
Warmup: write a declaration of a function that takes a pointer to "a function that takes double and returns a pointer to double" and returns a pointer to a pointer to "a function that takes int and returns a pointer to a pointer to int".
Exercise: write a function that takes an array of integers and returns the array of the same integers sorted (do not use any external functions); the function should not modify the initial array.
Exercise (*): write a function that takes a system of affine equations and returns a solution of the system (do not use any external functions).
Lesson 2: the runtime
During the lesson we shall learn basic concepts of C++ runtime: organization of a memory, names, variables, values, bindings, environment, references, pointers, etc.
Exercise 1: write a function:
that takes:
Exercise 2: write a function:
that takes:
Exercise 1: write a function:
double newtonMethod(double (*f)(double), double (*df)(double), double x, int n); |
- a function f
- the derivative function df of f
- an initial point x
- a number of iterations n
Exercise 2: write a function:
double secondOrderMethod(double (*f)(double), double (*df)(double), double (*ddf)(double), double x, int n); |
- a function f
- the derivative function df of f
- the second derivative function ddf of f
- an initial point x
- a number of iterations n
- approximate f by the second order expansion of f at x, call this approximation g
- find roots y, z of g
- if |f(y)| < |f(z)| then x = y, otherwise x = z; if g does not have any root then perform one step of Newton method
Sources from Lesson 1
Lesson 1: introduction
During the lesson we shall do some simple number crunching in C++ and recall basic properties of floating-point arithmetic. Exercise - find a root of a given function by:
- bisection method
- false-point method
- secant method
- Newton method
- second-order expansion (you can use functions from cmath)
Attendance list
Assessment
There will be numerous short weekly assignments plus some extra problems (for higher grades only).