Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science We use computers, but the focus is on applied problem solving. One of my favorite videos talks about computer sciencecomputer science.

Similar presentations


Presentation on theme: "Computer Science We use computers, but the focus is on applied problem solving. One of my favorite videos talks about computer sciencecomputer science."— Presentation transcript:

1 Computer Science We use computers, but the focus is on applied problem solving. One of my favorite videos talks about computer sciencecomputer science 6/3/14

2 Sign up to be a mentor. $300 stipend

3 In English, if you were asked to give a definition of a fern, the following would be frowned upon: fern: a flowerless plant that has feathery or leafy fronds in the shape of a fern In computer science, we love the self-definition! 6/3/14

4 Self Similarity In Nature Ever noticed that within a fern's leaf or in a snowflake, the same branching pattern occurs at different spatial scales? These same self-similar patterns exist in mathematics and in many powerful computer science algorithms.

5 Some of you have seen self definition in mathematics: a i represents the i th element of a sequence. a 1 = 3 a n = 2 a n–1 + 1 What sequence does it generate? In mathematics and computer science, we call self-definition recursion. 6/3/14

6 This is a little more complicated self-definition: a 1 = 1 a 2 = 1 a n = a n–1 + a n–2 for n > 2 6/3/14

7 Finding the self-definition takes some practice. See if you can arrange the shapes you have been given into a bigger figure of the same shape – self-similar. Here is one example. Notice that the two smaller triangles form a bigger triangle of the same shape. 6/3/14

8 Were you able to make the similar shapes? 6/3/14

9 Self Similarity In Nature Many mathematical principles are based on ideals, and apply to an abstract, perfect world. This perfect world of mathematics is reflected in the imperfect physical world, such as in the approximate symmetry of a face divided by an axis along the nose. More symmetrical faces are generally regarded as more aesthetically pleasing. Symmetry- Bilateral

10 Self Similarity In Nature Five axes of symmetry are traced on the petals of this flower, from each dark purple line on the petal to an imaginary line bisecting the angle between the opposing purple lines. The lines also trace the shape of a star. Symmetry- Radial

11 Self Similarity In Nature Many natural objects, such as frost on the branches of a tree, show the relationship where similarity holds at smaller and smaller scales. This fractal nature mimics mathematical fractal shapes where form is repeated at every scale. Fractals, such as the famous Mandelbrot set, cannot be represented by classical geometry Fractals

12 Self Similarity In Nature Rabbits, rabbits, rabbits. Leonardo Fibonacci was a well-travelled Italian who introduced the concept of zero and the Hindu-Arabic numeral system to Europe in 1200AD. He also described the Fibonacci sequence of numbers using an idealized breeding population of rabbits. Each rabbit pair produces another pair every month, taking one month first to mature, and giving the sequence 0,1,1,2,3,5,8,13,... Each number in the sequence is the sum of the previous two. Fibonacci Sequence

13 Self Similarity In Nature If you construct a series of squares with lengths equal to the Fibonacci numbers (1,1,2,3,5, etc) and trace a line through the diagonals of each square, it forms a Fibonacci spiral. Many examples of the Fibonacci spiral can be seen in nature, including in the chambers of a nautilus shell. Fibonacci Spiral The Fibonacci sequence represented mathematically fib(1)=1 fib(2)=1 fib(n)=fib(n-1)+fib(n-2)

14 Self Similarity In Nature Fibonacci Spiral

15 Another recursive algorithm ffgdgfdddddddfsfsdfsdfsfdsdfsddddddddddd 6/3/14

16

17

18 Algorithms (steps for solving a problem) are sometimes self-similar Consider this problem: After graduation, you are asked to design a system for breaking a chocolate bar into small chunks. How many steps are required to break an m × n sized bar of chocolate into 1 × 1 pieces? You can break an existing piece of chocolate horizontally or vertically. You cannot break two or more pieces at once (so no cutting through stacks). 6/3/14 Notice how the problem is self similar. If the problem is called “break(m,n)” define the problem for me recursively.

19 How many breaks does it take for a bar with m rows and n columns? What is the optimal way to break it? Let’s use the think-pair-share technique. Come up with your own solutions, compare with a neighbor, and then share with the group. 6/3/14

20 Consider the following famous problem in computer science: The knapsack problem You have the following length of board 51, 50, 42, 32, 30, 22, 21, 20, 11, 10, 8 You want to select the segments so that you have a total length of exactly 127. 6/3/14

21 What pieces do you select? How do you define the problem? In computer science, the language Python, defines a function as something that takes parameters and returns a value. 6/3/14

22 Suppose you had a friend who would solve any smaller problems for you, as long as they were of the same format. What would you have her do? # WRITE THE CODE TO determine if there is a solution (returns true or false) def solve_puzzle(gap, blocks): #returns True --> problem solvable, or False --> not solvable #gap is how much you have to fill #blocks is the lengths you can use 6/3/14

23 Suppose you had a friend who would solve any smaller problems for you, as long as they were of the same format. What would you have her do? # WRITE THE CODE TO determine if there is a solution (returns true or false) def solve_puzzle(gap, blocks): #returns True --> problem solvable, or False --> not solvable if gap == 0: #easy, no gap to fill return True if gap < 0: #over filled the gap return False if len(blocks) == 0: #run out of blocks return False ignore_block = solve_puzzle(gap, rest_of(blocks)) #dont use use_block = solve_puzzle(gap - first_of(blocks), rest_of(blocks)) #put in gap return use_block or ignore_block 6/3/14

24 For those that have never coded studio.code.org/s/artist For those that have coded before studio.code.org/p/artist If you have coded before: http://studio.code.org/p/artist 6/3/14

25 The boxes There are three boxes. One is labeled "APPLES" another is labeled "ORANGES". The last one is labeled "APPLES AND ORANGES". You know that EVERY BOX is labeled incorrectly. You may ask me to pick one fruit from ONLY one box which you choose. How can you label the boxes correctly? 6/3/14

26 Flipping Coins There are twenty coins sitting on the table, ten are currently heads and tens are currently tails. You are sitting at the table with a blindfold and gloves on. You are able to feel where the coins are, but are unable to see or feel if they heads or tails. You must create two sets of coins. Each set must have the same number of heads and tails as the other group. You can only move or flip the coins, you are unable to determine their current state. How do you create two even groups of coins with the same number of heads and tails in each group? 6/3/14

27 Towers of Hanoi – another recursive problem 6/3/14


Download ppt "Computer Science We use computers, but the focus is on applied problem solving. One of my favorite videos talks about computer sciencecomputer science."

Similar presentations


Ads by Google