mirror of
https://github.com/mfocko/blog.git
synced 2024-11-22 13:03:47 +01:00
pb071: refresh 3rd seminar bonus
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
7ed3cd3298
commit
1ae9a34e70
1 changed files with 77 additions and 7 deletions
|
@ -5,8 +5,21 @@ description: |
|
||||||
Select sort implementation on arrays.
|
Select sort implementation on arrays.
|
||||||
---
|
---
|
||||||
|
|
||||||
This assignment has two versions. For the light version you can get 0.5 K₡. For
|
:::caution
|
||||||
the _full fat_ one 1 K₡. **You can choose only one of them**.
|
|
||||||
|
Deadline for the submission of the bonus is **March 16th 24:00**.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
In case you have any questions, feel free to reach out either by email, Discord
|
||||||
|
or just by submitting an issue [here](https://gitlab.fi.muni.cz/xfocko/kb/-/issues/new).
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
This assignment has two versions. For the light version you can get 1.5 K₡. For
|
||||||
|
the _full fat_ 3 K₡. **You can choose only one of them**.
|
||||||
|
|
||||||
To both of them you are given some basic tests. You can also have a look at the
|
To both of them you are given some basic tests. You can also have a look at the
|
||||||
code used by the tests and use it to your advantage.
|
code used by the tests and use it to your advantage.
|
||||||
|
@ -38,12 +51,69 @@ For the full fat version you have 4 functions to implement:
|
||||||
To 2nd and 3rd function you are given a pseudocode that you can use to implement
|
To 2nd and 3rd function you are given a pseudocode that you can use to implement
|
||||||
it.
|
it.
|
||||||
|
|
||||||
|
:::tip Function pointers
|
||||||
|
|
||||||
|
In the skeleton of the “full fat” version you might have noticed a weird type
|
||||||
|
signature of both the `maximum` and `select_sort` functions. Those functions get
|
||||||
|
passed a _function pointer_ to the comparator that you use for comparing the
|
||||||
|
respective elements in the passed in array.
|
||||||
|
|
||||||
|
If we take the parameter from one of the functions from the skeleton:
|
||||||
|
```c
|
||||||
|
int (*comp)(const void *, const void *)
|
||||||
|
```
|
||||||
|
|
||||||
|
`comp` is a function pointer to a function that takes two pointers of unspecified
|
||||||
|
type, i.e. pure address to the memory (you don't know what stored in there), and
|
||||||
|
returns an `int`.
|
||||||
|
|
||||||
|
You can pass the function by simply using its name. (There is no need to use `&`
|
||||||
|
to get its address.) And you can also call the function by “calling” the function
|
||||||
|
pointer, e.g. `comp(left, right)`.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Submitting
|
## Submitting
|
||||||
|
|
||||||
Ideally submit the assignment through the merge request. Step-by-step tutorial is
|
For submitting the bonus assignment you can follow the same procedure as for
|
||||||
present [here](../mr). For setting assignee my xlogin is `xfocko`.
|
submitting the homeworks, that is:
|
||||||
|
|
||||||
In case you do not want to experiment on GitLab, send me the source code via email,
|
1. On branch `main` add the provided skeleton.
|
||||||
but please prefix subject with: `[PB071/14][seminar-03]`
|
2. Checkout new branch `seminar-bonus-03`.
|
||||||
|
3. Add your solution to the newly created branch.
|
||||||
|
4. Create a MR to the `main` branch with me (`@xfocko`) as the reviewer.
|
||||||
|
|
||||||
Deadline for the submission of the bonus is **March 27th 24:00**.
|
:::tip Directory structure for bonuses
|
||||||
|
|
||||||
|
Ideally create a directory `seminar-bonuses` in the root of your repository with
|
||||||
|
bonuses in their own subdirectories.
|
||||||
|
|
||||||
|
Structure of your repository can look like this:
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── bonuses
|
||||||
|
│ └── seminar-03
|
||||||
|
├── hello
|
||||||
|
├── hw01
|
||||||
|
├── hw02
|
||||||
|
├── seminar-01
|
||||||
|
├── seminar-02
|
||||||
|
└── seminar-03
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── bonus-seminar-03
|
||||||
|
├── hello
|
||||||
|
├── hw01
|
||||||
|
├── hw02
|
||||||
|
├── seminar-01
|
||||||
|
├── seminar-02
|
||||||
|
└── seminar-03
|
||||||
|
```
|
||||||
|
|
||||||
|
Structure of the bonuses is entirely up to you, just keep it consistent.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
Loading…
Reference in a new issue