WARM UP ========================================================== Greatest Common Divisor (aka Euclid's algorithm) ========================================================== 1) Write the algorithm in pseudocode see: a) the lecture (page 4) https://moodle.mimuw.edu.pl/pluginfile.php/272773/mod_resource/content/1/WyklWI-C.pdf b) the wikipedia https://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations 2) Write the program in C (all three versions: modulo, substraction, recursion) Requirements: a) take two integers (m, n) from stdin b) return GCD in stdout ========================================================== ========================================================== Least Common Multiple ========================================================== https://en.wikipedia.org/wiki/Least_common_multiple Given the relationship: LCM * GCD = m * n Modify the algorithm/program to get both GCM & LCM at the stdout ========================================================== SORTING Work in pairs: 1. Go to ./ex1 directory a) watch sort1.gif b) write the sorting scheme in pseudocode c) write C program which implements the pseudocode d) assess the complexity of the algorithm 2. Go to ./ex2 directory a) watch sort2.gif b) write the sorting scheme in pseudocode c) write C program which implements the pseudocode d) assess the complexity of the algorithm Hints: - use 'sizeof' - swap (also without tmp variable) - you can also print sorting progress #ex1 https://en.wikipedia.org/wiki/Insertion_sort #ex2 https://en.wikipedia.org/wiki/Bubble_sort Homework: 1) read about three, randomly selected sorting algorithms and be prepared to explain them in front of the class (the idea, pseudocode, complexity) 2) answer to the question which sort algorithm is the best and why? 3) C coding - pointers (with emphasis on returning arrays via function) https://pl.wikibooks.org/wiki/C/Wska%C5%BAniki_-_wi%C4%99cej http://fizyka.umk.pl/~leii/wskaznikiAiR.pdf - structures https://pl.wikibooks.org/wiki/C/Typy_z%C5%82o%C5%BCone#Struktury - DEFINE https://www.techonthenet.com/c_language/constants/create_define.php Food for thought: Discovering faster matrix multiplication algorithms with reinforcement learning https://doi.org/10.1038/s41586-022-05172-4