Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

6.00_learner Group Title

Hi guys, the ideas of graph and dynamic programming seem confuse me a lot. In lec22's code. the subtitles indict that there is a bug in function dpShortestPath(). I don't understand that code very well. How does the bug arise? Could any one explain that problem more concretely or just give the correct code? lec22's code http://dpaste.com/hold/1396904/

  • 11 months ago
  • 11 months ago

  • This Question is Closed
  1. Richard_C Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    It's fun to watch the video lectures, but it's a headache to just go through the codes...

    • 11 months ago
  2. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    you need to work with it till you understand how it works. you might have to watch the lecture a few times. just keep at it till you understand it then look for the bug. to be candid it has been a long while since i went thru it and i don't recall what the bug was. maybe go back and re-watch lecture 21 also

    • 11 months ago
  3. 6.00_learner Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    In lec23 about 24:30 , Prof Guttag claims there is a dirty little secret in python. initializing the memo = None and doing a little bit change of code may be helpful.

    • 11 months ago
  4. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    why wouldn't you want to use a mutable object as a function argument default value ?

    • 11 months ago
  5. 6.00_learner Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Initializing the memo = None turns out to be a wrong answer…It makes no expecting change to the program. I think I can understand the function shortestPath() now, but still confuse about the dpShortestPath(). The only thing I am sure now is that dpShortestPath() indeed has a bug(s), and the bug must hide in the memo.

    • 11 months ago
  6. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    here is one of many explanations available for this gotcha http://effbot.org/zone/default-values.htm

    • 11 months ago
  7. 6.00_learner Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks, it begins to make a little sense to me. But those recursive relations are still very messy. Maybe I should take an algorithm course, then i can fully understand it.

    • 11 months ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.