Prioritization function needed (recursive help!)

R

rh0dium

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
 
P

Paul Rubin

rh0dium said:
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.
 
A

Arnaud Delobelle

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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top