Try giving some dummy names to the nodes which doesn't have any values. Then traverse the tree either using pre/post order techniques and store the values in array.
For the first example: Using preorder
Using A as root
A, A, V10, V9, A, V8, A, A, V7, V6, A, V5, A, A, V4, V3, A, V2, V1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.