Thread: How can I write a code to solve such problem? (dynammic programming)

  1. #1
    Registered User
    Join Date
    Oct 2014
    Posts
    1

    How can I write a code to solve such problem? (dynammic programming)

    Given a set S of m strings and a target string t we want to check whether or not t is the concatenation of some of the m strings while allowing repetition. Example : S= {ab, dbe, eaa, ea} and t=eaabdbeab. Here the answer is YES, t=ea ab dbe ab.

    Key: I know that I should solve this using dynamic programming and I got this hint :
    I should consider solving the following set of subproblems: can a prefix of T of length k be represented as a concatenation of some strings from S? These can be solved with a dynamic programming approach for all k from 1 up to the total length of T. The largest of these subproblems is the actual problem we want to solve.
    But how can I write the code?

    Thank you.
    Last edited by Salem; 10-14-2014 at 12:03 PM. Reason: removed code tags

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Well, I'm happy you seemed to have scanned over the rules and used code tags - but you're only supposed to use them on code, not your actual question.

    You also posted in the "general discussions" forum, so we don't know which language you're supposed to be using for this assignment.

    Please see the homework policy - you need to attempt solving the problem yourself, and ask specific questions when you get stuck. "How can I write this code" is too general of a question to answer, and nobody is going to do your entire assignment for you.

    Finally, don't cross-post your question to various forums. It's bad etiquette.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me solve this programming question please......
    By kavi.84 in forum C Programming
    Replies: 3
    Last Post: 07-10-2012, 05:09 AM
  2. Replies: 8
    Last Post: 11-19-2011, 01:29 AM
  3. Replies: 3
    Last Post: 10-31-2011, 04:33 AM
  4. Help me solve this programming error please
    By rushhour in forum C++ Programming
    Replies: 20
    Last Post: 01-03-2009, 02:11 PM
  5. Dynammic programming - optimal Routes Listing
    By Sober in forum C++ Programming
    Replies: 10
    Last Post: 08-26-2008, 01:37 PM

Tags for this Thread