🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.pascal
Article #219

Help with Pascal program

#219
From: Ronald Gross
Date: Sun, 10 Nov 1985 17:58
30 lines
1421 bytes
I need help with the following tree program.  I don't want to write 
any more tree programs.

Given the preorder and inorder traversals of a binary tree, build the tree
and print the postorder traversal of it.

Read the input read into two lists.  The tree should be built using
pointers.

The algorithm goes like this.  Given LIST1 (preorder) and LIST2 (inorder).
The first node of LIST1 is the root of the tree.  This node is in the
middle of LIST2, and partitions it into left and right sublists.  LIST1 is
then partitioned into sublists.  Apply this recursively.

Please have the program echo the input, use lots of routines (makes for
easier reading.

Thanks alot.  Oh yeah, here's some test data.

LIST1		LIST2
-----		-----

A		A
ABDEHCFGI	DBHEAFCGI
BCA		ABC		(this will give an error)


	Thanx alot folks.  Your help is appreciated.

				Ronny
Technical Details
Message-ID: <2047@aecom.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!aecom!rgross
References: <206@ur-tut.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/5/84; site aecom.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!aecom!rgross
From: rgross@aecom.UUCP (Ronald Gross)
Newsgroups: net.lang.pascal
Subject: Help with Pascal program
Message-ID: <2047@aecom.UUCP>
Date: Sun, 10-Nov-85 12:58:03 EST
Article-I.D.: aecom.2047
Posted: Sun Nov 10 12:58:03 1985
Date-Received: Wed, 13-Nov-85 04:43:44 EST
References: <206@ur-tut.UUCP>
Distribution: net
Organization: Albert Einstein Coll. of Med., NY
Lines: 30