Ask Question
22 July, 06:22

Onsider the following pseudocode function. function Crunch (x R) if x ≥ 100 then return x/100 else return x + Crunch (10 · x) (a) Compute Crunch (4). Crunch (4) = (b) What happens if you try to compute Crunch (-23) ? What does this suggest about an appropriate precondition for this function?

+2
Answers (1)
  1. 22 July, 08:37
    0
    A) Crunch (4) = 4 + Crunch (40)

    ... = 4 + 40 + Crunch (400)

    ... = 4 + 40 + 400/4

    ... = 48

    b) Crunch (-23) = - 23 + Crunch (-230)

    ... = - 23 - 230 + Crunch (-2300)

    ... terminates with overflow or memory exception

    An appropriate precondition is x ≥ 0.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Onsider the following pseudocode function. function Crunch (x R) if x ≥ 100 then return x/100 else return x + Crunch (10 · x) (a) Compute ...” in 📙 Mathematics if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers