Prioritization function needed (recursive help!)

Discussion in 'Python' started by rh0dium, Jan 21, 2008.

  1. rh0dium

    rh0dium Guest

    Hi all,

    I need some help on writing a recursive priority function

    Given a list = [ A, B, C, D]

    Where the following constraints are in place:

    A depends on [B, C]
    C depends on

    Figure out real order that prioritizes these.

    Output [ B, C, A, D ] is valid. (Actually D could be anywhere in it
    as it doesn't matter..)

    I am really struggling on simply how to organize the data and write
    the corresponding function - I tried classes but I don't know if
    that's the best approach. See my other post on this.

    Thanks
     
    rh0dium, Jan 21, 2008
    #1
    1. Advertising

  2. rh0dium

    Paul Rubin Guest

    rh0dium <> writes:
    > I am really struggling on simply how to organize the data and write
    > the corresponding function - I tried classes but I don't know if
    > that's the best approach. See my other post on this.


    We just had a discussion thread about this. Is it a homework problem?

    Anyway, look up "topological sorting" in a CS textbook or on Wikipedia.
     
    Paul Rubin, Jan 21, 2008
    #2
    1. Advertising

  3. On Jan 21, 10:30 pm, rh0dium <> wrote:
    > Hi all,
    >
    > I need some help on writing a recursive priority function
    >
    > Given a list = [ A, B, C, D]
    >
    > Where the following constraints are in place:
    >
    > A depends on [B, C]
    > C depends on
    >
    > Figure out real order that prioritizes these.
    >
    > Output [ B, C, A, D ] is valid.  (Actually D could be anywhere in it
    > as it doesn't matter..)
    >
    > I am really struggling on simply how to organize the data and write
    > the corresponding function - I tried classes but I don't know if
    > that's the best approach.  See my other post on this.
    >
    > Thanks


    There's a very recent thread on this subject (topological sort)

    --
    Arnaud
     
    Arnaud Delobelle, Jan 21, 2008
    #3
  4. rh0dium

    Kent Johnson Guest

    Kent Johnson, Jan 21, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AlanR
    Replies:
    6
    Views:
    463
    Hugo Pragt
    Oct 6, 2003
  2. n00m
    Replies:
    12
    Views:
    1,116
  3. vamsi
    Replies:
    21
    Views:
    2,083
    Keith Thompson
    Mar 9, 2009
  4. Mark Piffer
    Replies:
    9
    Views:
    911
    luserXtrog
    May 15, 2009
  5. Alok
    Replies:
    3
    Views:
    254
Loading...

Share This Page