2 ms·
You don't need parent pointers. For converting binary tree into a linked list in O(n) time and O(1) space. You have two pointers, the root and the tail (right
by orange_county 10y ago
You don't need parent pointers.
For converting binary tree into a linked list in O(n) time and O(1) space.
You have two pointers, the root and the tail (right child node).
If root has a left subtree, set tail->right = left subtree. Update tail again so it is the last right child node.
root = root->right
Repeat until root is NULL
- catnaroek 10y agoThanks!