CS61A HOMEWORK 8 SOLUTIONS

CS61A HOMEWORK 8 SOLUTIONS

Let us call the required stream of numbers s and notice the following facts about it. Some of the problems use a utility method called timeit , which takes a parameterless function as argument, executes it, and returns the time required to do so. Use only a single line for the body of the function. These are called regular numbers. Derive Sum Question

Therefore, even if c returns False , the function t will be called. Implement a data abstraction for exponentiation: A famous problem, first raised by Richard Hamming, is to enumerate, in ascending order with no repetitions, all positive integers with no prime factors other than 2, 3, or 5. Implement derive-sum , a procedure that differentiates a sum by summing the derivatives of the addend and augend. Iterating from n-1 to 1, we return the first integer that evenly divides n. The max function can take an arbitrary number of arguments.

One obvious way to do this is to simply test each integer in turn to see whether it has any factors other than 2, 3, and 5. This sequence of values of n is often called a Hailstone sequence, Write a function that takes a single argument with formal parameter name nprints out the hailstone sequence starting at nand returns the number of steps in the sequence:. Symbolic differentiation is of special historical significance in Lisp.

cs61a homework 8 solutions

Your solution must use only the functions defined in the skeleton, without defining any additional ones. The derive Scheme procedure takes an algebraic expression and a variable and returns the derivative of the expression with respect to the variable.

  BTN HOMEWORK DEBATE

Homework 8 | CS 61A Spring

Stream of Streams Differentiation Question 9: These are called regular numbers. But this is very inefficient, since, as the integers get larger, fewer and fewer of them fit the requirement. Linear Congruential Generator Extra questions Question 8: Implement derive-productwhich applies the product rule to differentiate products:.

cs61a homework 8 solutions

Use only a single line for the body of the function. Use data abstraction for a sum:.

Homework Questions

Likewise, any lambda expressions should contain only calls to these functions. If you have any questions about using OK, please refer to this guide. Now all we have to do is combine elements from these sources.

You may check the solutions if you are stuck, but we highly recommend you work through the problem on your own for practice. It returns a list with the elements of sbut with each word that occurs in the second argument replaced by the corresponding word of the third argument. Make Exp Question Some of the problems use a utility method called timeitwhich takes a parameterless function as argument, executes it, and returns the time required to do so. Define a function that returns a stream of random numbers that uses this linear-congruential formula.

Missing Value Question 2: Write a function that takes an integer n that is greater than 1 and returns the largest integer that is smaller than n and evenly divides n. Analogously, a hailstone travels up and down in the atmosphere before eventually landing on earth. Write a function that takes three positive numbers and returns the sum of the squares of the two largest numbers. See Lab 0 for more instructions on submitting assignments.

  THESIS UHASSELT RECHTEN

As an alternative, we can build a stream of such numbers. Differentiating is a recursive process that applies different rules to different kinds of expressions:. It returns a list with the homewirk of sbut with every occurrence of old replaced by neweven within sub-lists. Fill in the blanks in the following function definition for adding a to the absolute value of bwithout calling abs.

When you are done, submit with python3 ok –submit.

Homework 1 Solutions | CS 61A Summer

Implement derive-expwhich uses the power rule to derive exps:. Therefore, even if c returns Falsethe function t will be called. You may submit more than once ds61a the deadline; only the final submission will be scored. Scale Stream Question 6: Derive Product Question Sub All Streams Question 5: