Binary tree generation from transveral strings

Tanya Katz tanya at adds.newyork.NCR.COM
Wed Mar 7 05:13:54 AEST 1990


Does anyone have an algorithm (or a reference to one)
that creates a unique binary tree from the prefix & postfix 
transversal strings of a general tree?

Given the prefix & postfix transversal of a general tree, you are
supposed to be able to generate a unique binary tree. The infix 
transversal string of this binary tree equals the postfix string 
of the general tree.  This can be done recursively, I am told. 

eg:  
General tree definition:
Prefix string:  abdgcehif
Postfix string:	gdbhiefca  = Infix string of binary tree

binary tree:
		  a
	         /
		b
	       / \
	      d   c
             /   / 
            g   e
	       / \
	      h   f
	       \
		i

Any help would be appreciated.  Ideas/pseudo code, 'C', Pascal... help...

-Tanya


+------------------------------------------------+
| Tanya Katz                  (516)231-5400 x430 |
|                                                |
|          ...uunet!ncrlnk!adds!tanya            |
|         tanya.katz at adds.newyork.ncr.com        |
|                                                |
| ADDS Inc, 100 Marcus Blvd, Hauppauge, NY 11788 |
+------------------------------------------------+



More information about the Comp.lang.c mailing list