Define a Fibonacci tree of order k as a root whose left subtree has order k-1 and whose right subtree has order k-2. Nodes are labeled by their one-based preorder position. Compute paths without materializing t…
Question
Define a Fibonacci tree of order `k` as a root whose left subtree has order `k-1` and whose right subtree has order `k-2`. Nodes are labeled by their one-based preorder position. Compute paths without materializing the tree.
```python
def tree_size(order: int) -> int: ...
def fib_path(order: int, start: int, end: int) -> list: ...
def fib_directions(order: int, start: int, end: int) -> list: ...
def fib_lca(order: int, start: int, end: int) -> int: ...
```
## Requirements
- Use `tree_size(k) = F(k+2) - 1`, with `F(0)=0` and `F(1)=1`.
- `fib_path` returns node labels from `start` to `end`, inclusive.
- `fib_directions` returns `"Up"` steps to the lowest common ancestor, then `"Left"` or `"Right"` steps downward.
- Validate that labels lie within the requested tree.
- Order zero is an empty tree, order one is a single root, and subtrees of order zero or below are empty. Public orders must be non-negative non-boolean integers; labels must be non-boolean integers in `1..tree_size(order)`. Raise `ValueError` otherwise, including path queries on an empty tree. Equal endpoints return a single-label path and no directions.
- The supplied `run_case` is fixture dispatch glue. Underscored helpers are optional; implement the four listed interfaces.
- Time and memory should depend on tree height, not total node count.
For example, `fib_path(4, 4, 7)` returns `[4, 3, 2, 1, 6, 7]`.
## Design discussion (not graded)
1. Support very large orders where sizes exceed fixed-width integers.
2. Return only path length without constructing the path.
3. Answer many path or LCA queries for the same order.
The public brief is identical for people and crawlers. Account access changes tools, not the indexed description.