2017-03-13

posted Mar 13, 2017, 6:50 AM by Samuel Konstantinovich   [ updated Mar 13, 2017, 11:30 PM ]
 Homework:1. Refresh your memory of basic turtle movement commands, and NetLogo functions/procedures.2. Complete your fib(n) function in python.  3. What is the largest n you can calculate in fib(n) that completes in less than 5 seconds? (start with lower numbers and then try larger as you test)Describe the following problems using both:  -recursive definition(s)  -base case(s)Do not write the function, just the rules for when you recurse, and when you stop.You need at least 2 parts to each answer, the 3rd and 4th require more parts.ALL QUESTIONS SHOULD BE ANSWERED ON PAPER in your notebooks. You do not have to copy the entire question, just enough to understand what you are writing about. (e.g. function name, or answer with complete sentences.)0- Whatever you do not complete, must be completed at home!1. countDigits(n)  - how many digits are in the number2. myLen(s) - how many characters are in the string (without using len)3. countFives(n)  - how many fives are in the number4. countMatching(s)   -   how many consecutive matching characters in a string. e.g.  'aabcccd' has 3 matching (overlap counts twice)Fibonacci 5. Calculate the first 15 elements of the sequence, and time yourself. (Starts with 0)6. Extrapolate: How long would it take to calculate the 50th term? (estimate based on your data)7. How long would it take the computer? (guess)