subject

Write a recursive procedure to implement the following function hotpo(n): hotpo(nhotpon/2) >l is even hotpo 3 n+1) n>1 n is odd n words: 1. The procedure takes a natural number n(n1) as input; 2. If n is even, divide it by 2 to getn12; 3. If n is odd, multiply it by 3 and add 1 to obtain 3n+1. 4. Repeat the process until the result is 1. The procedure stops and returns 1 For example, if the input value is 3, the procedure will have the following recursive calls: (hotpo 3) (hotpo 10)- (hotpo 5)(hotpo 16) (hotpo 8) (hotpo 4)(hotpo 2)- (hotpo 1) (1) Give the complete Scheme procedure and use comments to mark the size-n problem, stopping condition and return value, size-m problem, and construction of size-n problem solution. [5 points] (define hotpo (lambda (n)
(2) Modify the program in (1): Add a second parameter, named counter, into the hotpo procedure. The counter will count the number of iterations (the number of reentrances) that the procedure will execute before it stops. The revised procedure should return the counter value. For example, (hotpo 3 counter) should return 7. 3 points] (define hotpo (lambda (n counter)

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 10:00, serenityharmon1
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
image
Computers and Technology, 24.06.2019 17:30, leenzazou98241
What is the next step if your volume does not work on computer
Answers: 2
image
Computers and Technology, 25.06.2019 02:30, LilCookies1
Ahammer should not be applied to the gear shafts of an electric rotisserie because the shafts may be made of
Answers: 1
image
Computers and Technology, 25.06.2019 04:30, babas97
What is the purpose of network permissions? a)to control access to network resources b)to convert to wireless networking c)to enable the installation of nics d)to reduce operating costs
Answers: 1
You know the right answer?
Write a recursive procedure to implement the following function hotpo(n): hotpo(nhotpon/2) >l is...

Questions in other subjects:

Konu
Social Studies, 17.06.2021 06:50
Konu
Mathematics, 17.06.2021 06:50
Konu
Mathematics, 17.06.2021 06:50