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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 24.06.2019 17:30
Match the following. 1. formatting that is applied when cell data meets certain criteria 2. borders with formats not found on the border tool 3. a shortcut bar that contains tools for commonly used formats 4. formats that can be applied to numbers conditional formatting custom borders format bar number formats
Answers: 3
question
Computers and Technology, 24.06.2019 17:50
You will subnet the network address 172.31.103.0/24. the network has the following requirements: · room-114 lan will require 27 host ip addresses · room-279 lan will require 25 host ip addresses · room-312 lan will require 14 host ip addresses · room-407 lan will require 8 host ip addresses how many subnets are needed in the network topology?
Answers: 2
You know the right answer?
Write a recursive procedure to implement the following function hotpo(n): hotpo(nhotpon/2) >l is...
Questions
question
English, 28.09.2019 00:00
question
Geography, 28.09.2019 00:00
Questions on the website: 13722362