On John Guttag's lecture 3 - problem solving, he asks the class to find the decrementimg function of the while loop finding the cubed root of an integer. How did he derive abs(x)-ans^3 as the decrementing function? It's not blatantly stated in the code.
what is the min:sec mark of that statement in the lecture?
Around 6:17. I thought a decrementing function would be stated plainly in the code.
2011 or 2008 class i'll go watch that portion, what exactly are you expecting when you say "I thought a decrementing function would be stated plainly in the code"
he pulled abs(x)-ans^3 out of thin air. Just wondering if I'm supposed to evaluate the while loop and state the decrementing function I think its saying overall, or if I missed something. That abs(x)-ans^3 isn't in there. Its the lecture 3 on this link: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/unit-1/lecture-3-problem-solving/
so he isn't saying that there is actually a line of code that is a decrementing function. he is trying to show you a tool that will help you ensure that a loop will terminate. if you can construct a decrementing function that meets the conditions that he set forth then your loop should terminate - as long as you translate that function into a usable condition for your loop
Join our real-time social learning platform and learn together with your friends!