or just by submitting an issue <ahref="https://gitlab.fi.muni.cz/xfocko/kb/-/issues/new"target="_blank"rel="noopener noreferrer">here</a>.</p></div></div><p>This assignment has two versions. For the light version you can get 1.5 K₡. For
the <em>full fat</em> 3 K₡. <strong>You can choose only one of them</strong>.</p><p>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.</p><p>Details can be found in the doxygen comments included in the source files.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="light-version-main_lightc">Light version (<code>main_light.c</code>)<ahref="#light-version-main_lightc"class="hash-link"aria-label="Direct link to light-version-main_lightc"title="Direct link to light-version-main_lightc"></a></h2><p><ahref="/files/pb071/bonuses/03/main_light.c"target="_blank"rel="noopener noreferrer">Source</a></p><p>For the light version you have 3 functions to finish:</p><ol><li><code>swap</code> - that swaps two ints passed by pointers.</li><li><code>maximum</code> - that returns index of the biggest <code>int</code> in the array.</li><li><code>select_sort</code> - that sorts passed array using Select Sort.</li></ol><h2class="anchor anchorWithStickyNavbar_LWe7"id="full-fat-version-mainc">Full fat version (<code>main.c</code>)<ahref="#full-fat-version-mainc"class="hash-link"aria-label="Direct link to full-fat-version-mainc"title="Direct link to full-fat-version-mainc"></a></h2><p><ahref="/files/pb071/bonuses/03/main.c"target="_blank"rel="noopener noreferrer">Source</a></p><p>For the full fat version you have 4 functions to implement:</p><ol><li><code>swap</code> - that swaps two variables passed by pointers.</li><li><code>maximum</code> - that returns index of the biggest element in the array using the
comparator.</li><li><code>select_sort</code> - that sorts passed array using Select Sort.</li><li><code>int_comparator</code> - that is used for generic sort and maximum</li></ol><p>To 2nd and 3rd function you are given a pseudocode that you can use to implement
it.</p><divclass="theme-admonition theme-admonition-tip alert alert--success admonition_LlT9"><divclass="admonitionHeading_tbUL"><spanclass="admonitionIcon_kALy"><svgviewBox="0 0 12 16"><pathfill-rule="evenodd"d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>Function pointers</div><divclass="admonitionContent_S0QG"><p>In the skeleton of the “full fat” version you might have noticed a weird type
signature of both the <code>maximum</code> and <code>select_sort</code> functions. Those functions get
passed a <em>function pointer</em> to the comparator that you use for comparing the
respective elements in the passed in array.</p><p>If we take the parameter from one of the functions from the skeleton:</p><divclass="language-c codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#000000;--prism-background-color:#ffffff"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-c codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#000000"><spanclass="token keyword"style="color:rgb(0, 0, 255)">int</span><spanclass="token plain"></span><spanclass="token punctuation"style="color:rgb(4, 81, 165)">(</span><spanclass="token operator"style="color:rgb(0, 0, 0)">*</span><spanclass="token plain">comp</span><spanclass="token punctuation"style="color:rgb(4, 81, 165)">)</span><spanclass="token punctuation"style="color:rgb(4, 81, 165)">(</span><spanclass="token keyword"style="color:rgb(0, 0, 255)">const</span><spanclass="token plain"></span><spanclass="token keyword"style="color:rgb(0, 0, 255)">void</span><spanclass="token plain"></span><spanclass="token operator"style="color:rgb(0, 0, 0)">*</span><spanclass="token punctuation"style="color:rgb(4, 81, 165)">,</span><spanclass="token plain"></span><spanclass="token keyword"style="color:rgb(0, 0, 255)">const</span><spanclass="token plain"></span><spanclass="token keyword"style="color:rgb(0, 0, 255)">void</span><spanclass="token plain"></span><spanclass="token operator"style="color:rgb(0, 0, 0)">*</span><spanclass="token punctuation"style="color:rgb(4, 81, 165)">)</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p><code>comp</code> 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 <code>int</code>.</p><p>You can pass the function by simply using its name. (There is no need to use <code>&</code>
to get its address.) And you can also call the function by “calling” the function
pointer, e.g. <code>comp(left, right)</code>.</p></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="submitting">Submitting<ahref="#submitting"class="hash-link"aria-label="Direct link to Submitting"title="Direct link to Submitting"></a></h2><p>For submitting the bonus assignment you can follow the same procedure as for
submitting the homeworks, that is:</p><ol><li>On branch <code>main</code> add the provided skeleton.</li><li>Checkout new branch <code>seminar-bonus-03</code>.</li><li>Add your solution to the newly created branch.</li><li>Create a MR to the <code>main</code> branch with me (<code>@xfocko</code>) as the reviewer.</li></ol><divclass="theme-admonition theme-admonition-tip alert alert--success admonition_LlT9"><divclass="admonitionHeading_tbUL"><spanclass="admonitionIcon_kALy"><svgviewBox="0 0 12 16"><pathfill-rule="evenodd"d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>Directory structure for bonuses</div><divclass="admonitionContent_S0QG"><p>Ideally create a directory <code>seminar-bonuses</code> in the root of your repository with