recursion - Java binary tree postorder traversal recursively -


// trying return list containing values in 'a' traversing nodes in postorder. in junit says "string cannot cast list". please.

public static list postorder(tree a) {         if (a.getempty())              return list.empty();          else               postorder(a.getleft());               postorder(a.getright());                return listops.append(postorder(a.getleft()),                          list.cons(a.getvalue(), postorder(a.getright())));             } 

i think problem here: listops.append(.. because question totally unclear, think listops string, method return list...

so use arraylist or class implement list, , add elements it...


Comments