Submit | All submissions | Best solutions | Back to list |
HS11BST - Search Tree |
A sequence of n integers has been inserted into a binary search tree (before the operation the tree was empty). The tree stores unique elements, only, and all duplicates are simply ignored.
Please print in ascending order all the tree elements whose depth is equal to h-1, where h is the height of the tree.
Input
First n (2<=n<=100000) - the number of integers in the sequence. In the next n lines the sequence of integers, one integer xi (-1000000 < xi < 1000000) in each line. You can assume that the height of the tree will be at least 1.
Output
The requested integers, one integer in each line.
Example
Input: 8 3 1 8 5 3 12 9 8 Output: 5 12
Scoring
By solving this problem you score 10 points.
Added by: | kuszi |
Date: | 2011-12-06 |
Time limit: | 0.206s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32 BASH BF C CSHARP C++ 4.3.2 CPP C99 CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO HASK ICON ICK JAVA JS-RHINO LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PERL6 PHP PIKE PRLG-swi PYTHON PYTHON3 RUBY SCALA SCM guile SCM qobi ST TCL WHITESPACE |
Resource: | High School Programming League 2011/12 |