Update tuto

This commit is contained in:
Miloslav Ciz 2022-04-02 22:19:38 +02:00
parent d4d83bf6c1
commit decd2bd9d5
6 changed files with 296 additions and 27 deletions

View file

@ -3,17 +3,16 @@
Here let be listed exercises for the readers of this wiki. You can allow yourself to as many helpers and resources as you find challenging: with each problem you should either find out you know the solution or learn something new while solving it.
1. What's the difference between [free software](free_software.md) and [open source](open_source.md)?
2. Say we have an algorithm that finds all pairs of equal numbers in an array of numbers of length *N* and adds all of these (unordered) pairs to a set *S*. The algorithm is: `for i := 0 to N: for j := 0 to N: if numbers[i] == numbers[j]: add(S,pair(i,j))`. How can we optimize the algorithm in terms of its execution speed (i.e. make it perform fewer operations)? How did the asymptotic time complexity ("big O") class change?
2. Say we have an algorithm that finds all pairs of equal numbers in an array of numbers of length *N* and adds all of these (unordered) pairs to a set *S*. The algorithm is (pseudocode): `for i := 0 to N: for j := 0 to N: if numbers[i] == numbers[j]: add(S,pair(i,j))`. How can we optimize the algorithm in terms of its execution speed (i.e. make it perform fewer operations while keeping its results the same)? How did the asymptotic time complexity ("big O") class change?
3. In computer graphics, what is the difference between ray casting, ray tracing and path tracing?
## Solutions
A solution to each problem should be listed here -- keep in mind there may exist other solutions that those listed here.
**solution 1**:
Both movements share very similar rules of licensing and technically free software and open-source are largely the same. However, free software is fundamentally aiming for the creation ethical software -- that which respects its user's freedom -- while open source is a later movement that tries to adapt free software for the business and abandons the pursuit of ethics.
Both movements share very similar rules of licensing and technically free software and open-source are largely the same. However, free software is fundamentally aiming for the creation of ethical software -- that which respects its user's freedom -- while open source is a later movement that tries to adapt free software for the business and abandons the pursuit of ethics, i.e. it becomes corrupted by capitalism and no longer minds e.g. proprietary dependencies.
**solution 2**:
@ -21,7 +20,7 @@ In the given algorithm we compare all numbers twice. This can be avoided by not
```
for i := 0 to N:
add(S,i,i) // no need to compare
add(S,i,i) // no need to compare
for i := 0 to N:
for j := i + 1 to N:
@ -29,7 +28,7 @@ for i := 0 to N:
add(S,pair(i,j))
```
While the first algorithm performs N^2 comparisons, the new one only needs N - 1 + N - 2 + N - 3 + ... ~= N * N / 2 = N^2 / 2 comparisons. Even though the new version is always twice as fast, its time complexity class remains the same, that is O(N^2).
While the first algorithm performs N^2 comparisons, the new one only needs N - 1 + N - 2 + N - 3 + ... ~= N * N / 2 = N^2 / 2 comparisons. Even though the new version is always twice as fast, its time complexity class remains the same, that is O(N^(2)).
**solution 3**: