[OT] Retreating from Iraq
Benji Smith
dlanguage at benjismith.net
Mon Oct 13 15:29:10 PDT 2008
BCS wrote:
>> Sort everyone under you (directly or indirectly) by the number of
>> subordinates they have. Pick the subordinate with the most
>> subordinates and call the next man in line to them. remove every
>> subordinate down that chain of command and repeat.
>>
>> This assumes that the depth of command is more or less the same across
>> the board.
>>
>
> This is based on the ssumption that the people with the most
> subordinates need to get started first.
But consider this case...
I have two subordinates: Dirk and Deek. Dirk has only one subordinate of
his own, but Deek has three. It seems like I should call Deek first.
But what if Dirk's single subordinate has twenty subordinates of his
own, which Deek's subordinates are leaf-nodes? In that case, it makes a
whole lot more sense to call Dirk first.
So it seems essential to implement a cost function for each branch of
the tree. Something more elaborate than just counting each person's
subordinates.
But a weighted-subtree function isn't the right approach either.
Consider this case (with JSON-y goodness):
A: {
B: [ B1, B2, B3, B4, B5, B6, B7, B8 ],
C: {
C1: [ C1a, C1b, C1c ],
C2: [ C2a, C2b, C2c ]
}
}
In this case, "A" has two subordinates: "B" and "C". If I calculate my
cost function by summing the number of subordinates under each officer,
"B" and "C" seem to have identical cost, since they have a total of
eight subordinates each.
The cost of any soldier "s" can be calculated like this:
1 + max(s.subordinateCount(), + s.mostExpensiveSubordinate())
Each officer should contact his subordinates in decreasing-cost order.
--benji
More information about the Digitalmars-d
mailing list