59
University of Ljubljana Andrej Brodnik Nataša Mori Decembe r 1, 2014

University of Ljubljana Andrej Brodnik Nataša Mori December 1, 2014

Embed Size (px)

Citation preview

  • Slide 1
  • University of Ljubljana Andrej Brodnik Nataa Mori December 1, 2014
  • Slide 2
  • Slovenia 2
  • Slide 3
  • 3 Over 2 million inhabitants 20.273 km 1991 independence 2004 EU member 4 public universities
  • Slide 4
  • Ljubljana 4 The University is based in Ljubljana, the capital of Slovenia, a relatively large Central-European city with over 300,000 inhabitants.
  • Slide 5
  • University of Ljubljana 5 45.607 students 9.904 graduates 5.893 employees an annual budget of app. 300 mio Established in 1919 with 5 member schools 23 faculties and 3 arts academies
  • Slide 6
  • Achievements 2013 6 Among the top 500 universities according to: Times THSE-QS Ranking: 500-600 Shanghai Academic Ranking of World Universities: 400-500 Webometrics Ranking of World universities: top 200 University Ranking by Academic Performance (URAP): 284
  • Slide 7
  • Faculty of Computer and Information Science FRI December 1, 2014
  • Slide 8
  • The Investment programme Novogradnja UL FKKT in UL FRI directly contributes to the realization of the key priority of the Operational Programme for Strengthening Regional Development Potentials of Slovenia for the Period 2007- 2013: Economic development infrastructure. Investment means establishing conditions for encouraging and forming of more innovative and technologically advanced economy as well as opening more value-added employment possibilities. 8
  • Slide 9
  • Information about the building The FKKT net area is 24,882 m2, of which 7,436 m2 is parking space The FRI net area is 13,177 m2, of which 3,081 m2 is parking space Net area of the building X is 3.987 m2 Altogether 40.370 m2 There are 8 lecture halls altogether 9
  • Slide 10
  • Information about the FRI building 66 offices 22 laboratories 7 smaller lecture halls, 2 larger lecture halls 74 projectors 10
  • Slide 11
  • Faculty of Computer and Information Science Chair of Mathematics and Physics Laboratory for Mathematical Methods in Computer and Information Science Laboratory for Cryptography and Computer Security Chair of Theoretical Computer Science Laboratory for Algorithms and Data Structures Laboratory for Architecture and Signal Processing Software Engineering Laboratory Chair of Software Laboratory for Computer Graphics and Multimedia Laboratory for Biomedical Computer Systems and Imaging Laboratory for Ubiquitous Systems LUSY 11
  • Slide 12
  • Chair of Computer Logic, Systems and Network Laboratory for Adaptive Systems and Parallel Processing Laboratory for Computer Architecture Computer Communications Laboratory Computer Structures and Systems Laboratory Chair of Artificial Intelligence Computer Vision Laboratory Visual Cognitive Systems Laboratory Artificial Intelligence Laboratory Laboratory for Cognitive Modelling Bioinformatics Laboratory Chair of Informatics Information Systems Laboratory Laboratory of e-media Laboratory for Data Technologies Laboratory for Integration of Information Systems 12
  • Slide 13
  • What do have in common linear function and Towers of Hanoi? Andrej Brodnik 1,2, Nataa Mori 1 1 University of Ljubljana, FRI 2 University of Primorska, DIST University of Vilnius Vilnius, December 1 st, 2014
  • Slide 14
  • Towers of Hanoi Towers of Hanoi is also named Braman towers. It is built from series of 64 narrowing golden disks with hole in the middle. Disks are mounted on a stick and Bramans need to move them according to special rules to another stick. When they will move the last disk the story predicts end of the World. When can we expect the end of the World? What do have in common linear function and Towers of Hanoi?
  • Slide 15
  • Computer Science and Informatics English: Computer Science French: informatique German: Informatik Italian: informatica Swedish: datavetenskap Russian: ... What do have in common linear function and Towers of Hanoi?
  • Slide 16
  • What is Computer Science? The Joint Task Force for Computing Curricula 2005: Computing Curricula 2005 The Overview Report. ACM, september 2005. http://www.acm.org/education/curricula-recommendations http://www.acm.org/education/curricula-recommendations What do have in common linear function and Towers of Hanoi?
  • Slide 17
  • How does CS look in school? (The Royal Society). What do have in common linear function and Towers of Hanoi?
  • Slide 18
  • Map of a stroll From a line to the function Encapsulation, abstraction, modularization Function and algorithm Sequential and parallel computing mostly left out Towers of Hanoi Recursion, time complexity https://lusy.fri.uni-lj.si/redmine/projects/cs-edu https://lusy.fri.uni-lj.si/redmine/projects/cs-edu What do have in common linear function and Towers of Hanoi?
  • Slide 19
  • Linear function y = k x + n y = x; y = -x; y = 2x + 1 n offset and k angle We can also write as: f(x) = k x + n f 1 (x)= x; f 2 (x)= -x; f 3 (x)= 2x + 1 What do have in common linear function and Towers of Hanoi?
  • Slide 20
  • Linear function a bit differently f 1 (x)= x: Description: function f 1 (x) calculates value of coordinate y for any value of x with linear function y= x f 2 (x)= -x: Description: function f 1 (x) calculates value of coordinate y for any value of x with linear function y= -x f 3 (x)= 2x + 1: Description: function f 1 (x) calculates value of coordinate y for any value of x with linear function y= 2x+1 Encapsulation. What do have in common linear function and Towers of Hanoi?
  • Slide 21
  • Encapsulation function f 1 () (magically) calculates value of coordinate y at any given x We need to know what f 1 () does and not how; We need its signature: function f1(x): Description: calculates y using y= x Parameters: integer/real number x Result: integer/real number y What do have in common linear function and Towers of Hanoi?
  • Slide 22
  • Linear function a bit differently We have functions f 1 (x)= x f 2 (x)= -x f 3 (x)= 2x + 1 Could we generalize functions without defining these many functions? Reuse Abstraction/generaliziation. What do have in common linear function and Towers of Hanoi?
  • Slide 23
  • Abstraction All three functions will be abstracted (generalized) into a single one: function f(x, k, n): Description: calculates y using y= k*x+n Parameters: integer/real number x, angle k and shift n Result: integer/real number y Our functions can now be written as: f 1 (x)= f(x, 1, 0) f 2 (x)= f(x, -1, 0) f 3 (x)= f(x, 2, 1) What do have in common linear function and Towers of Hanoi?
  • Slide 24
  • Our abstract function has a problem Formulation f(x, 1, 0) does not look like a linear function We add a friend make Modularization What do have in common linear function and Towers of Hanoi? make_lf(k, n) {...} f(x) {...} k= --- n= ---
  • Slide 25
  • On our journey We started at mathematical functions We introduced expressions encapsulation, abstraction and modularization Encapsulation, abstraction and modularization are the basic techniques used in Computer Science What do have in common linear function and Towers of Hanoi?
  • Slide 26
  • Map of a stroll From a line to the function Encapsulation, abstraction, modularization Function and algorithm Sequential and parallel computing mostly left out Towers of Hanoi Recursion, time complexity What do have in common linear function and Towers of Hanoi?
  • Slide 27
  • Let us try with this game 1 2 3 4 5 6 7 8 9 10 32 26 52 68 75 33 7 17 66 93 What do have in common linear function and Towers of Hanoi?
  • Slide 28
  • What do we get? 3 2 5 7 8 4 0 1 6 9 1 2 3 4 5 6 7 8 9 10 32 26 52 68 75 33 7 17 66 93 1 2 3 4 5 6 7 8 9 10 7 17 26 32 33 52 66 68 75 93 4 3 6 8 9 5 1 2 7 10 +1 Computational thinking What do have in common linear function and Towers of Hanoi?
  • Slide 29
  • Drawing drawing lines is actually drawing points ta del izpuen What do have in common linear function and Towers of Hanoi?
  • Slide 30
  • Function and algorithm With planning of algorithms we can use game Algorithms are sequential and parallel as well as deterministic and random What do have in common linear function and Towers of Hanoi?
  • Slide 31
  • On our journey We started with a mathematical function We learned about encapsulation, abstraction and modularization Followed subroutines, signatures and pseudocode For a function planning we used methods divide and conquer and recursion What do have in common linear function and Towers of Hanoi?
  • Slide 32
  • Map of a stroll From a line to the function Encapsulation, abstraction, modularization Function and algorithm Sequential and parallel computing mostly left out Towers of Hanoi Recursion, time complexity What do have in common linear function and Towers of Hanoi?
  • Slide 33
  • Towers of Hanoi Problem states: Towers of Hanoi is also named as Braman towers. It contains 64 narrowing golden disks with hole in middle. Discs are assembled on stick and Bramans need to move them to another stick according to rule: Smaller disc always has to be ON bigger disc. How to find accurate sequence of moves use what we have: (i) function, (ii) divide and conquer, (iii) encapsulation, (iv) recursion What do have in common linear function and Towers of Hanoi?
  • Slide 34
  • Towers of Hanoi what What: hanoi(start, end, intermediate, n) Description: move n disc from start stick to end stick using intermediate stick for disposal. Example: move(left, right, middle, 5) move(left, right, middle, 64) What do have in common linear function and Towers of Hanoi?
  • Slide 35
  • Towers of Hanoi how How: if n = 0: we do nothing if n = 1: move disc from start stick to end stick If x > 1: (i) move away the top most n-1 discs from the start stick to the intermediate stick using the end stick as an intermediate one move the bottom most (n th ) disc from the start stick to the end stick (ii) move n-1 discs, that we moved away, from the intermediate stick to the end stick using the start stick as an intermediate stick What do have in common linear function and Towers of Hanoi?
  • Slide 36
  • Towers of Hanoi how Steps (i) and (ii) are actually the same as: (i) move away the top most n-1 discs from the start stick to the intermediate stick using the end stick as an intermediate one hanoi(start, intermediate, end, n-1) (ii) move n-1 discs, that we moved away, from the intermediate stick to the end stick using the start stick as an intermediate stick hanoi(intermediate, end, start, n-1) What do have in common linear function and Towers of Hanoi?
  • Slide 37 1) hanoi(z, v, k, n-1) printf("from %s on %s\n", z, k) hanoi(v, k, z, n-1) endif endfunction What do have in common linear function and Towers of Hanoi?">
  • Towers of Hanoi how function hanoi(z, k, v, n) Description: move n disc from start stick to end stick at which you can dispose some on intermediate stick. if (n == 0) elseif (n == 1) printf("from %s to %s\n", z, k) else # if (n > 1) hanoi(z, v, k, n-1) printf("from %s on %s\n", z, k) hanoi(v, k, z, n-1) endif endfunction What do have in common linear function and Towers of Hanoi?
  • Slide 38
  • Towers of Hanoi the whole story Tower of Hanoi is also named Braman tower. It contains 64 sets for narrowing golden discs with hole in middle. Discs are mounted on stick and Bramans need to move them to another stick according to special rule. When the last disc is moved the world will end. and when the World will end? What do have in common linear function and Towers of Hanoi?
  • Slide 39 1) hanoi(z, v, k, n-1) printf("from %s to %s\n", z, k) hanoi(v, k, z, n-1) endif endfunction Move lasts: 10 s manual move 5 s robotic move 1 ms mental move How many moves are required?">
  • Towers of Hanoi and end of World Movig disc in our program is printing description What do have in common linear function and Towers of Hanoi? function hanoi(z, k, v, n) Description: move n disc from start to end stick with disposing some on intermediate stick. if (n == 0) elseif (n == 1) printf("from %s to %s\n", z, k) else # if (n > 1) hanoi(z, v, k, n-1) printf("from %s to %s\n", z, k) hanoi(v, k, z, n-1) endif endfunction Move lasts: 10 s manual move 5 s robotic move 1 ms mental move How many moves are required?
  • Slide 40 1) hanoi(z, v, k, n-1) printf("from %s to %s\n", z, k) hanoi(v, k, z, n-1) endif endfunction and for some k? T(k) = T(k-1) + c + T(k-1) = 2 T(k-1) + c T(1)= c T(2)= 2 T(1) + c = 3c... T(n)= 2T(n-1) + c = 2(2T(n-2) + c) + c = 4T(n-2)+3c">
  • Towers of Hanoi and T(n) What is T(n) Counting: n = 1: T(1) = 1c n = 2: T(2) = 3c... What do have in common linear function and Towers of Hanoi? function hanoi(z, k, v, n) Description: moves n disc from start stick to end stick with disposing some on intermediate stick. if (n == 0) elseif (n == 1) printf("from %s to %s\n", z, k) else # if (n > 1) hanoi(z, v, k, n-1) printf("from %s to %s\n", z, k) hanoi(v, k, z, n-1) endif endfunction and for some k? T(k) = T(k-1) + c + T(k-1) = 2 T(k-1) + c T(1)= c T(2)= 2 T(1) + c = 3c... T(n)= 2T(n-1) + c = 2(2T(n-2) + c) + c = 4T(n-2)+3c
  • Slide 41
  • Towers of Hanoi and T(n)... What do have in common linear function and Towers of Hanoi? T(n)= 2T(n-1) + c = 2(2T(n-2) + c) + c = 4T(n-2)+3c = 2 2 (2 T(n-3) + c) + 3c = 2 3 T(n-3) + 2 2 c + 3c = 2 3 T(n-3) + 2 2 c + (2 1 + 2 0 )c = 2 3 T(n-3) + (2 2 + 2 1 + 2 0 )c =... = 2 n-1 T(n (n-1)) + (2 n-2 + 2 n-3 +... + 2 2 + 2 1 + 2 0 )c = 2 n-1 T(1) + (2 n-2 + 2 n-3 +... + 2 2 + 2 1 + 2 0 )c = 2 n-1 c + (2 n-2 + 2 n-3 +... + 2 2 + 2 1 + 2 0 )c = (2 n-1 + 2 n-2 + 2 n-3 +... + 2 2 + 2 1 + 2 0 )c
  • Slide 42
  • Towers of Hanoi and T(n)... What do have in common linear function and Towers of Hanoi? T(n)= (2 n-1 + 2 n-2 + 2 n-3 +... + 2 2 + 2 1 + 2 0 )c = (2 - 1)*(2 n-1 + 2 n-2 + 2 n-3 +... + 2 2 + 2 1 + 2 0 ) / (2-1) *c = (2 n - 1) *c = O(2 n )
  • Slide 43
  • Towers of Hanoi and movements Movement of disc in our program is description of move Move duration: 10 s manual move 5 s robotic move 1 ms mental move What do have in common linear function and Towers of Hanoi?
  • Slide 44
  • How much time has passed since Modern human: 50,000 years First humanoid: 200,000 years Life on Earth: 3.5 billion years What do have in common linear function and Towers of Hanoi? manual1,8 10 20 s5.849.424.173.550 years robotic9,2 10 19 s2.924.712.086.775 years thought1,8 10 16 s 584.942.417 years Earth creation: 4.5 billion years Big-Bang: 13.8 billion years
  • Slide 45
  • Conclusion Learning Computer Science should develop young people into technology designers and creators rather than merely technology users a philosophy of creativity and expression trather than mere productivity. What do have in common linear function and Towers of Hanoi?
  • Slide 46
  • Thank you for your attention! [email protected] [email protected] What do have in common linear function and Towers of Hanoi? Skill of using washing powder is not knowledge of Chemistry.
  • Slide 47
  • When will be the end of the world? and how much is T(n): in one year approximately 31.536.000 s T(35) = 17.179.869.184 -> 5.000 years of manual moving for 36 1.000 years... for 64 that is 2 64-36 thousands years, which is 268 billion years What do have in common linear function and Towers of Hanoi?
  • Slide 48
  • When will be the end of the world? calculate T(n): What do have in common linear function and Towers of Hanoi? function result= countMoves(n) if (n == 1) result= 1 else result= 2 * countMoves(n-1) + 1 endif printf("%d: %d\n", n, result) endfunction
  • Slide 49
  • Tower of Hanoi and the end of the world lets say that we have to do T(n)= 1.234.567 moves, then this will take: 12.345.670 s = 142 days 21 hours 21 min 10 s at manual moving; 6.172.835 s = 71 days 10 hours 40 min 35 s at robotic moving; and 1.234,567 s = 20 min 34 s 567 ms at thought moving one move takes c key number is T(n) What do have in common linear function and Towers of Hanoi?
  • Slide 50
  • Drawing we take a ruler, make two points and draw a line through the points where is the dwarf in the computer, who used the ruler? in computer we can draw only one point at a time example: program octave and function plot in it plot([1, 2, 3], [1, 2, 3], "@11) before we go to drawing a line, lets see the plot What do have in common linear function and Towers of Hanoi?
  • Slide 51
  • plot ..., which means to draw plot() looks like our function f() function plot(x, y, fmt): Description: draw points with x coordinate and y coordinate, where it considers the format of drawing fmt Parameters: list x coordinates of points; list y coordinates of points; instruction for shape of the drawing fmt... Result: ?? function can do something and return nothing side-effect What do have in common linear function and Towers of Hanoi?
  • Slide 52
  • Subroutine function with no return(void) is called also a subroutine, procedure back to plot and drawing a line What do have in common linear function and Towers of Hanoi?
  • Slide 53
  • Drawing a line we know: plot can draw points, which are given as lists of x and y coordinates if we give the function so many points, that we could not distinguish them, we would get an effect of a line in computer science the world is not continuous, but discrete how can we get a list of points? What do have in common linear function and Towers of Hanoi?
  • Slide 54
  • Calculation of the points If we have a hammer, then everything looks like a nail also a screw. Idea: write a function, which will calculate points note: for the purposes of this lecture we will only write the points on the screen, which otherwise makes their usage for drawing difficult How the function looks like? How to draw it? What do have in common linear function and Towers of Hanoi?
  • Slide 55
  • Calculation of the points We will write points from the starting x to the final xFin with a step delta: points(x, delta, xFin, k, n) Description: draw points of the function kx+n from given x to final xFin with a step delta. That is what, now how? What do have in common linear function and Towers of Hanoi?
  • Slide 56
  • Calculation of the points What: points(x, delta, xFin, k, n) Description: draw points of the function kx+n from given x to final xFin with a step delta. How: if x > xFin: do nothing if x
  • Calculation of the points What (signature): points(x, delta, xFin, k, n) Description: draw points of the function kx+n from given x to final xFin with a step delta. How (pseudocode): if x > xFin: do nothing if x
  • Calculation of the points... points(x, delta, xFin, k, n) Description: draw points of the function kx+n from given x to final xFin with a step delta. if (x > xFin) endif # (1) else # if (x
  • Calculation of the points What: points(x, delta, xFin, k, n) Description: draw points of the function kx+n from given x to final xFin with a step delta. How: if x > xFin: do nothing if x