The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Dynamic programming by Michiel2005-05-05 12:57:10
  I'm William, and I'll be your assitant for this by williamashbless2005-05-05 15:48:54
    There's a bit of a timezone-difference. :) by Michiel 2005-05-06 00:51:41
But sure.

Lets give it another try, then. There is an existing function L(i, j) that gives me the length Li + Li+1 + ... + Lj. Here's the pseudo-code. (comparison: =, assignment: <-)
ALGORITHM MinCost(i, j)
    // Recursively computes the minimum cost of this cutting-problem.
    // Input: Which subproblem to handle: from final log i to j
    // Output: The minimum cost for that subproblem
    if i = j
        return 0
    minC = MinCost(i+1, j)
    for x <- i+1 to j-1 do
        if MinCost(i, x) + MinCost(x+1, j) < minC
            minC <- MinCost(i, x) + MinCost(x+1, j)
    return L(i, j) + minC
How's that? Still not sure how to proceed from here, though. Even though I've never actually written this down, I've gone over it a couple of times in my head.
[ Reply ]
      Is that algorithm right? by ToLazyToThink2005-05-06 09:24:48
        Excelent point, but by Michiel2005-05-06 09:37:55
          I've replied in _today's_ thread. (n/t) by williamashbless2005-05-06 09:46:02

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)