Thread: finding the largest ascending subsequence..

  1. #16
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    the only solution that i have in mind in calling this function from inside a for loop
    from another function

    but unfortunately i am not allwed to use loops ,external function

    its all has to be done in this function in a recursive way


    ??
    (i can add parameters to the signature)

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Well, the function just has to be recursive in several ways. It has to recurse through the array to start at different starting points; it has to recurse over an element, skipping over it; and it has to recurse, counting an element (if it is greater than the previous element). At least my implementation that I whipped up did.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i dont know how to do this multy tasking recursion

    how am i supposed to do that?

  4. #19
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    how am i supposed to store the result of one task
    while doing another one??

  5. #20
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    I believe this would be a great way to get started on it http://cboard.cprogramming.com/showp...21&postcount=7

  6. #21
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    Quote Originally Posted by itCbitC View Post
    I believe this would be a great way to get started on it http://cboard.cprogramming.com/showp...21&postcount=7
    i've done plenty of that

  7. #22
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    did you try googling the thread title?.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  8. #23
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    no i dont
    i am thinking of how to combine then into one recursion

  9. #24
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Quote Originally Posted by transgalactic2 View Post
    no i dont
    i am thinking of how to combine then into one recursion
    There is an good algorithm to do this.

    wikipedia.org/wiki/Longest_increasing_subsequence
    Last edited by stevesmithx; 01-14-2009 at 01:49 AM.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  10. #25
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    whats the algorithm
    ??

  11. #26
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    Quote Originally Posted by stevesmithx View Post
    There is an good algorithm to do this.

    wikipedia.org/wiki/Longest_increasing_subsequence
    this algorithm is iterative "for" on external function

    i thought of that already

    it doesnt help me at all

  12. #27
    Registered User TriTon's Avatar
    Join Date
    Dec 2008
    Posts
    5
    maybe you should take something like this:
    http://www.algorithmist.com/index.ph..._Subsequence.c

    and try to convert all the loops into recursion.

  13. #28
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i saw this
    its too complicated for me
    there is no way i could convert it to a recursive form

  14. #29
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by transgalactic2 View Post
    i saw this
    its too complicated for me
    there is no way i could convert it to a recursive form
    And how do you propose we solve that problem?

    Of course, you can remove ALL of the prev variables, as they are just set, never referenced.

    You can also remove best if you only want to find ONE max value.

    --
    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.

  15. #30
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    i got this article
    but its so abstract

    i dont know how to use their words
    http://tclab.kaist.ac.kr/~otfried/cs500/09-dp.pdf

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 22
    Last Post: 05-29-2009, 05:44 PM
  2. Finding the 3 largest numbers of the five entered
    By Bkgrant in forum C Programming
    Replies: 11
    Last Post: 02-13-2009, 01:08 PM
  3. finding the largest number in a binary search
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 07-31-2008, 03:19 AM
  4. Find largest and second largest number (help)
    By Arkon in forum C++ Programming
    Replies: 6
    Last Post: 01-20-2006, 11:21 PM
  5. Finding largest element in array
    By Chaplin27 in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2005, 09:18 PM