Trees — Inserting in a binary search tree

Write a program that forms a binary search tree from a given sequence of
natural numbers. Each new integer must be placed at the only leaf that
allows to mantain the propierty of the binary search trees. The repeated
elements must be ignored.

Input

Input is a non empty sequence of natural numbers.

Output

Your program must print the preorder traversal of the resulting tree.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:59:35.535Z

© Jutge.org, 2006–2026.
https://jutge.org
