function PostOrder = PostOrderAlg(ChildrenList)
% PostOrder = PostOrderAlg(ChildrenList)
PostOrder = PostOrderRecursiveAlg(ChildrenList,[]);
function PostOrder = PostOrderRecursiveAlg(ChildrenList,PostOrder)
%PostOrder = PostOrderRecursiveAlg(ChildrenList,PostOrder)
%Input: ChildrenList: m + 1 column matrix (of integers) for an m-ary tree
%Output: PostOrder: a vector containing the postorder list of the vertices
if nnz(ChildrenList)== 1 %tree consists only of root
PostOrder = [PostOrder ChildrenList(1,1)];
end
if nnz(ChildrenList)> 1 %root has children
ChildChildrenLists = ChildTrees(ChildrenList);
[r c s] = size(ChildChildrenLists); % s = number of children trees
for i = 1:s
PostOrder = PostOrderRecursiveAlg(ChildChildrenLists(:,:,i),PostOrder);
end
PostOrder = [PostOrder ChildrenList(1,1)];
end