Ask your own question, for FREE!
Mathematics 14 Online
OpenStudy (anonymous):

Consider the following pseudocode function. function Crunch(x is in R) if x ≥ 100 then return x/100 else return x + Crunch(10 · x) (a) Compute Crunch(5). Crunch(5) =

OpenStudy (anonymous):

@e.mccormick

OpenStudy (anonymous):

(b) What happens if you try to compute Crunch(−23)? What does this suggest about an appropriate precondition for this function?

OpenStudy (zzr0ck3r):

crunch(5) since x is not >= 100 return x + Crunch(10 · x) = 5+crunch(10*5) = 5+crunch(50) crunch 50 will return 50+crunch(50*10) so we have 5+50+crunch(500) crunch 500 will return 500/100 = 5 so crunch(5) returns 5+50+5 = 60

OpenStudy (zzr0ck3r):

I think

OpenStudy (zzr0ck3r):

Crunch(−23) will always crunch a number <= 100 so it will go in infinite loop, thus x needs to be positive

OpenStudy (anonymous):

Consider the following pseudocode function. function Crunch(x is in R) if x ≥ 100 then return x/100 else return x + Crunch(10 · x) (a) Compute Crunch(5). Crunch(5) = |dw:1371433544740:dw|

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!