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, 21.06.2019 23:30
Show that there is a language a ⚆ {0, 1} â— with the following properties: 1. for all x â a, |x| ≤ 5. 2. no dfa with fewer than 9 states recognizes a. hint: you don’t have to define a explicitly; just show that it has to exist. count the number of languages satisfying (1) and the number of dfas satisfying (2), and argue that there aren’t enough dfas to recognize all those languages. to count the number of languages satisfying (1), think about writing down all the strings of length at most 5, and then to define such a language, you have to make a binary decision for each string about whether to include it in the language or not. how many ways are there to make these choices? to count the number of dfas satisfying (2), consider that a dfa behaves identically even if you rename all the states, so you can assume without loss of generality that any dfa with k states has the state set {q1, q2, . . , qk}. now think about how to count how many ways there are to choose the other four parts of the dfa.
Answers: 3
question
Computers and Technology, 22.06.2019 08:30
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
question
Computers and Technology, 22.06.2019 10:30
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
You know the right answer?
Write a recursive procedure to implement the following function hotpo(n): hotpo(nhotpon/2) >l is...
Questions
question
Mathematics, 07.04.2020 19:26
Questions on the website: 13722363