Prg2 Inf Pátek 09.05.2025 1.Zápočtový program OWL: https://owl.mff.cuni.cz/join/b234cd6d7459 Enroll token: b234cd6d7459 2. Termíny zápočtových testů a Obhajob zápočtových programu - termiti Tabulka - ukázka 3. OPAKOVANI (recodex) DP úloha - Mrkev a přetrTržel Máme osít N záhonů. Na každém záhonu může být buď mrkev nebo petržel, avšak nikdy nesmí být žádné dva sousední záhony osety petrželí. Sestavte program, který ze standardního vstupu přečte počet záhonů N a na standardní výstup vypíše číslo P, kde P je počet různých přípustných osetí. Snažte se o efektivní výpočet. Vstupní číslo N nesmí být větší než 44. Pro výpočty použijte typ longint. Příklad: Vstup: 3 Výstup: 5 Vysvětlení: Pro tři záhony existuje 5 způsobů, jak je osít. 10. Threads - Fibonachi shared memory thread 10.1. Create 5 threads that each separately recursive manner count and print value of fibonachi number for input sequence from 3 to 40 10.2. Active waiting - Create 5 threads that each separately recursively count and print value of fibonachi number given by shared variable, in loop: if fb number is counted, wait random time and count fb number again if shared variable is changed 6. Filter Write a generic method T[] filter(T[] a, Predicate p) that selects only the elements of a for which the given predicate is true. 8. Generic sort Function with Comparator Write a generic function void sort(T[] a, Comparison f) that can sort an array using an arbitrary function to compare elements. The delegate type Comparison is defined in the standard library as follows: delegate int Comparison(T x, T y); Given two objects x and y of type T, a Comparison returns a negative value if x is less than y 0 if x equals y a positive value if x is greater than y You may use any sorting algorithm that you like. PRISTE 2. Cell Class - exceptions, comparators (throw exception, catch exception and define own excetion) 2.1 Define class Cell with atributes: a] float weight, b] float age which are set on creation 2.2 Throw exception mustByPositive on creation with negative value of weight or age; if value is negative set the value on default value; in case weight = 1.0 and in case age = 0.0 - create a new type of exception - mustBePositive 2.3 Create Properties to weight and age that throw exception mustBePositive, when negative value is try to set and keep current value 2.5 Create comparators that compare Cell objects by weight 2.5.1 Overloading < 2.5.2 Overiding CompareTo 2.7. Sort Cell objects by: 2.7.1 a] weight 2.7.2 b] age (Collection) 2.10. Create the corresponding test cases