Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. Consider a program P, which given the inputs b = #(big fruits in the basket X), s = #(sour fruits in X), and f
2. Consider a program P, which given the inputs b = #(big fruits in the basket X), s = #(sour fruits in X), and f = #all fruits in X). computes M = maximum number of fruits that could be both big and sour, and also computes m = mini- mum number of fruits that have to be both big and sour, (i) How do you know that P is no good if it outputs M = 8 for input (b, s, f) = (6, 7, 14)? (ii) Now suppose the program is modified and it outputs M = 6 for the above input but its other output m = 2. What can you say about the modified program and why? (iii) Give the code for computing M (= at most...) and m (= at least ...) from inputs b, s, and f. (iv) If we just want to compute M, what should be the inputs? What if we just want to compute m? 2. Consider a program P, which given the inputs b = #(big fruits in the basket X), s = #(sour fruits in X), and f = #all fruits in X). computes M = maximum number of fruits that could be both big and sour, and also computes m = mini- mum number of fruits that have to be both big and sour, (i) How do you know that P is no good if it outputs M = 8 for input (b, s, f) = (6, 7, 14)? (ii) Now suppose the program is modified and it outputs M = 6 for the above input but its other output m = 2. What can you say about the modified program and why? (iii) Give the code for computing M (= at most...) and m (= at least ...) from inputs b, s, and f. (iv) If we just want to compute M, what should be the inputs? What if we just want to compute m
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started