Hey guys, I'm having trouble with question 5 from the first quiz. I thought 'guess and check' was covered in lecture 5 in relation to calculating square roots so I tried this speculatively (it'll only work with ints so I kind of knew it was wrong): 1. calculate a max poss value for the answer 2. calculate a min poss value for the answer 3. set guess = minimum 4. while guess<= maximum if guess = answer +/- epsilon return guess increment guess Obviously this is absolutely nothing like the real answer which I can't make any sense of .... any help much appreciated ...
I would have answered something like this. Since the question says exhaustive, one have to enumerate through all the solutions, and test every guess. When you say it works only with int, you're right, but think of the solutions space like a totally ordered space. You always have a way to say that a guess is before or after another one. So it's similar to integers. I give you an A :)
lol! thanks maitre_kaio! That's what I thought, hence my confusion :) Having thought about it some more, I've realized that the answer they've given is more like the McNuggets problem set than the square roots example. Perhaps the question is just ambiguous, although that seems strange. Perhaps both answers are valid even though they haven't indicated it in the answers ... unless I'm still missing something ...
I didn't realize the answers were given in the course materials :) It seems to me that most of the quizz questions have several answers, and some questions (like this one) are pretty vague. I think the professort would have been glad with our answer.
You may well be right. I was a bit more concerned that I didn't really understand the answer that they gave; although I think I've figured it out ... I guess I'll just have to live with the ambiguity :(
Join our real-time social learning platform and learn together with your friends!