Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**Language is R5RS (SCHEME)** 1. Abstracting the summation of a series (a) Consider the harmonic numbers H,-- + + + . Last week you wrote

**Language is R5RS (SCHEME)**

image text in transcribed

1. Abstracting the summation of a series (a) Consider the harmonic numbers H,-- + + + . Last week you wrote a recursive ScHEME function (named harmonic) which, given a number n, computes H Revise your harmonic function, keeping the name (harmonic n), to take advantage of the sum function seen in the textbook (Sectiorn 1.3.1) and shown below: (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b))) Of course, your new and improved definition of harmonic should not be recursive itself and should rely on sum to do the hard work. (b) The above definition of sum is a recursive process. Write an iterative version sum-i that solves the same problems as sum in an iterative fashion. Demonstrate that it works by using it to define harmonic-i. (c) Show that your harmonic functions work for 1, 50, and 100. 1. Abstracting the summation of a series (a) Consider the harmonic numbers H,-- + + + . Last week you wrote a recursive ScHEME function (named harmonic) which, given a number n, computes H Revise your harmonic function, keeping the name (harmonic n), to take advantage of the sum function seen in the textbook (Sectiorn 1.3.1) and shown below: (define (sum term a next b) (if (> a b) 0 (+ (term a) (sum term (next a) next b))) Of course, your new and improved definition of harmonic should not be recursive itself and should rely on sum to do the hard work. (b) The above definition of sum is a recursive process. Write an iterative version sum-i that solves the same problems as sum in an iterative fashion. Demonstrate that it works by using it to define harmonic-i. (c) Show that your harmonic functions work for 1, 50, and 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

Finding and scheduling appointments with new prospective clients.

Answered: 1 week ago