Ask your own question, for FREE!
Mathematics 19 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!
Latest Questions
kaelynw: starting to draw a hand
1 day ago 16 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
2 days ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
1 hour ago 6 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
2 days ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
3 days ago 27 Replies 3 Medals
kaelynw: art igg
3 days ago 14 Replies 1 Medal
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!