Order parent tasks and subtasks by relative due dates using grouped subtree traversal, with explicit tie rules, cycle validation, and multiple valid outputs.
Given tasks with parent/subtask relationships and due dates, produce a display order that keeps each parent's subtask group together. A child whose due date is earlier than its parent's must be displayed before the parent; other children appear after the parent. Explain the data structure and traversal used to produce the order.
### Constraints & Assumptions
The source's separate filtering and general sorting rules are not supplied and are outside this extracted task. Assume unique task IDs and an acyclic forest. For nested subtasks, explicitly apply the rule recursively to whole child-subtree blocks. Equal due dates belong after the parent. Sibling blocks and root blocks may appear in any order; no unique output is required. Confirm these tie/nesting policies before implementing an original judge interface.
### Clarifying Questions to Ask
- Can subtasks themselves have children, or is there only one parent-child level?
- Should an earlier-due child move together with its entire subtree?
- Are equal-date children placed before or after their parent?
```hint Split a parent's child blocks
One group must be visited before emitting the parent, and the other after it.
```
### What a Strong Answer Covers
- A task-ID map and parent-to-children adjacency lists.
- Recursive ordering of earlier-child blocks, the parent, then remaining-child blocks.
- Exactly-once output, forest roots, and validation of malformed relationships.
### Follow-up Questions
- How would a filter treat a hidden parent whose child remains visible?
- How could an explicit stack avoid recursion limits for deeply nested tasks?
Overview: Order parent tasks and subtasks by relative due dates using grouped subtree traversal, with explicit tie rules, cycle validation, and multiple valid outputs.
Given tasks with parent/subtask relationships and due dates, produce a display order that keeps each parent's subtask group together. A child whose due date is earlier than its parent's must be displayed before the parent; other children appear after the parent. Explain the data structure and traversal used to produce the order.
Constraints & Assumptions
The source's separate filtering and general sorting rules are not supplied and are outside this extracted task. Assume unique task IDs and an acyclic forest. For nested subtasks, explicitly apply the rule recursively to whole child-subtree blocks. Equal due dates belong after the parent. Sibling blocks and root blocks may appear in any order; no unique output is required. Confirm these tie/nesting policies before implementing an original judge interface.
Clarifying Questions to Ask Guidance
Can subtasks themselves have children, or is there only one parent-child level?
Should an earlier-due child move together with its entire subtree?
Are equal-date children placed before or after their parent?
What a Strong Answer Covers Guidance
A task-ID map and parent-to-children adjacency lists.
Recursive ordering of earlier-child blocks, the parent, then remaining-child blocks.
Exactly-once output, forest roots, and validation of malformed relationships.
Follow-up Questions Guidance
How would a filter treat a hidden parent whose child remains visible?
How could an explicit stack avoid recursion limits for deeply nested tasks?