#ifndef lint
static char sccsid[] = "@(#)ptrmain.c	1.2 (UKC) 22/9/86";
#endif  lint

#include <stdio.h>
#include "ptr.h"

/*
 * Test program: construct ordered tree from random numbers
 */

static node_t *tree1;
static node_t *tree2;

main()
{
	int i;
	node_t *construct();
	void print(), add1(), add2();

	tree1 = construct();
	/* add tree to itself twice */
	tree2 = NULL;
	for (i=0; i<3; i++) {
		treewalk(preorder, tree1, add2);
		treewalk(preorder, tree2, add1);
	}
	exit(0);
}

node_t *
construct()
{
	node_t *root;
	int i;

	root = NULL;
	srand(123456);

	for (i=0; i<240; i++) addnode(&root, abs(rand()) % 999 + 1);

	return(root);
}

void
print(node)
node_t *node;
{
	printf("%4d", node->contents);
}

void
add1(node)
node_t *node;
{
	addnode(&tree1, node->contents);
}

void
add2(node)
node_t *node;
{
	addnode(&tree2, node->contents);
}
