The following iterative sequence is defined for the set of positive integers: Sn/2 if n is even = "n 3n +1 ifnis odd Using the rule above and starting with 13, we generate the following sequence: 13 u13 = 40 40 = 20 → U20 = 10 → U10 = 5 → U5 = 16→U16 =8us 4- u =2 u2 =1. It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. The below function takes as input an integer n and returns the number of terms generated by the sequence starting at n. function i-Seq(n) %3D %3D %3D %3D u-n3; i%-1%3B while u -1 if statement 1 u-u/2%3B else statement 2 end i=i+1; end statement l and statement 2 should be replaced by: statement 1 is 'mod(n,2)=D3D0 and statement 2 is "u 3*n+1," O None of the choices. statement 1 is 'u%2 and statement 2 is 'u = 3*u+1," O statement 1 is mod(u.2)==0 and statement 2 is U= 3*u+1,

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
The following iterative sequence is defined for the set of positive integers:
ifn is even
3n +1 ifnis odd
Using the rule above and starting with 13, we generate the following sequence:
20 u20 = 10 → U10 = 5 U5 = 16 u16 =8us = 4-
13 u13 40 u40=
u=2 u2 = 1.
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms.
The below function takes as input an integer n and returns the number of terms
generated by the sequence starting at n.
function i-Seq (n)
u-n;
1=1%B
while u -1
if statement 1
u-u/2%3;
else
statement 2
end
1=i+1%3B
end
statement 1 and statemet 2 should e replacerd bv:
statement 1 is 'mod(n.2)=30 and statement 2 is 'u - 3*n+1;"
O None of the choices
KO statement 1 is u%2 and statement 2 is u= 3*u+1;"
O statement 1 is mod(u.2)==0 and statement 2 is u= 3*u+1,"
op
Transcribed Image Text:The following iterative sequence is defined for the set of positive integers: ifn is even 3n +1 ifnis odd Using the rule above and starting with 13, we generate the following sequence: 20 u20 = 10 → U10 = 5 U5 = 16 u16 =8us = 4- 13 u13 40 u40= u=2 u2 = 1. It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. The below function takes as input an integer n and returns the number of terms generated by the sequence starting at n. function i-Seq (n) u-n; 1=1%B while u -1 if statement 1 u-u/2%3; else statement 2 end 1=i+1%3B end statement 1 and statemet 2 should e replacerd bv: statement 1 is 'mod(n.2)=30 and statement 2 is 'u - 3*n+1;" O None of the choices KO statement 1 is u%2 and statement 2 is u= 3*u+1;" O statement 1 is mod(u.2)==0 and statement 2 is u= 3*u+1," op
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education