Thread: Dynamic Programming

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Question Dynamic Programming

    I need to do a word wrap on a string using the dynamic programming method, I receive a const char* and return a formatted char*, can anyone help me?, It's the fisrt time I use dynamic programming and I don't understand how to use it in my problem.
    I know how to do it using the greedy method, but I need to use DP method.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Exactly what do you struggle with in that assignment? The actual "dynamic programming" part?

    I have no idea how to solve this particular problem with dynamic programming, but the wikipedia seems to contain several examples and descriptions:
    http://en.wikipedia.org/wiki/Dynamic_programming


    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    4
    hey i think i can help you with that but i don't understand exactly what your program suppose to do.
    can you give an example of the input you expect and the output you want to genarate
    thanks

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    2
    As input I can receive for example the string "this is a testing" and the width integer to format to the text, for example 7 and the output shoul be
    "this
    is a
    testing"
    in the input string I can receive any space caracter recognized by the function isspace() beetwen the words and calculating the cost using the square of the widht - length(words in line)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. dynamic array/vector help
    By Cpro in forum C++ Programming
    Replies: 8
    Last Post: 04-05-2008, 03:30 PM
  3. Identify dynamic IP address of network device
    By BobS0327 in forum Tech Board
    Replies: 2
    Last Post: 02-21-2006, 01:49 PM
  4. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM
  5. Dynamic memory confusion
    By ripper079 in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2002, 06:15 PM