如何構建二叉樹

給定一個樹的數組表示,按照前序,空節點用-1表示 例如vector<int> nums = {1,2,4,8,-1,-1,9,-1,-1,5,-1,-1,3,6,10,-1,-1,-1,7,-1,11,-1,-1} 算法如下:   input:     a[]   &i #as the current element in a[], reference data   root #the root
相關文章
相關標籤/搜索