jeudi 21 juillet 2016

construct general tree structure given preorder and postorder in java

I need to build a general tree structure recursively in Java by reading in preorder and postorder traversals like the ones given below:

K, H, B, G, M, W, F, T, X, Z, C, R, P, Q, N

G, M, W, F, B, X, Z, T, R, P, C, H, N, Q, K

Most of the code samples that I have found online only help with creating a binary tree structure and not a general tree structure.

I was wondering if someone can provide some sample code that can help me build a general tree structure recursively. thanks

Aucun commentaire:

Enregistrer un commentaire