Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 19 Online
OpenStudy (anonymous):

Problem Set 1 (C): So, I've done the problem set C but it is really different from the solution... Also, I want to know if what I've written is good or not... I'm pretty sure it's not working the right way, however, I don't understand how to write a program executing the bisection search Thanks for your time and help

OpenStudy (anonymous):

http://dpaste.com/1541035/

OpenStudy (anonymous):

So Bisection Search works by 'halving' your current working set of data until you can get to a close approximation to what it is you want to find. The variables you need are the 'high' end of what the answer could be and the 'low' end of what it could be. a minimum and maximum. Your answer should be somewhere within these two bounds. Upper and Lower Bounds. You also need an epsilon or approximation to where you want to be. A Target in this case it will be balance. being payed off. A current guess which is to add the low and high together and divide by two (which will give you a guess in the middle of the two bounds). You then test this guess. so in the credit card case it would be. current guess would be the minimum payment. When you run through the current 12 months and you have not payed enough we test against the balance. if balance <= epsilon (I set mine to 0.01 or one penny) then change high to the current guess (minimum payment) otherwise change the low to the current guess. This process will eliminate the other half by repeatedly changing either the upper or lower. It will zero in on the target.

OpenStudy (anonymous):

http://dpaste.com/hold/1541365/ ^^ This is my version

OpenStudy (anonymous):

As long as each time you pass through the loop your data you need to analyze is half the data it was the previous time you passed through it, you are doing good. If it's not the case you are doing it wrong. Be more specific with your question. Maybe Copy Paste the code containing the Bisection search here. One word of advice tho when you seek question about coding on the internet : Don't put your whole file as downloadable, just paste the small part you have problem with.

OpenStudy (anonymous):

Thanks All

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!