Suppose we are doing merge sort of A & B, of n_A and n_B elements.
If A, B, and output are stored as Vec, then we will need:
( n_A + n_B + (n_A + n_B) * sizeof(T) bytes of storage
- On the other hand, if we stored A, B, and outputa s Vec<Vec> … with the inner Vec having K elements, then at any given time, we will only need:
(n_A + n_B + K * 2) * sizeof(T) + (n_A/k + n_B/k)*sizeof(ptr) bytes of storage right?
Because if we into_iter A and B, we consume Vec’s of size K as we march along / allocate new blocks in the output.
- If the above is correct, does Rust have any crates built around Vec<Vec> ?