American Computer Science League Intermediate Division 2007 - 2008 Contest #4

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

ACSL

2007 - 2008 American Computer Science League Contest #4


Intermediate Division
Trees

PROBLEM: Given an input string, create the binary search tree for the string using the
rules provided in the ACSL description booklet.

INPUT: There will be 5 lines of input. Each line will contain a string of alpha
characters, a positive integer, and the alpha character L or R.

OUTPUT: For each input line, print the left child (L) or the right child (R) of the
character at the position in the string given by the positive integer. If none exists, then
print NONE. Sample Input #1 directs you to print the left child of R, the first character
in the string and Sample Input #2 directs you to print the right child of S, the sixth
character in the string.

E U

C R S V

C E I S U

F N T

I N O

SAMPLE INPUT SAMPLE OUTPUT

1. RECURSIVEFUNCTIONS, 1, L 1. E
2. RECURSIVEFUNCTIONS, 6, R 2. U
3. RECURSIVEFUNCTIONS, 10, L 3. NONE
4. RECURSIVEFUNCTIONS, 15, R 4. NONE
4. RECURSIVEFUNCTIONS, 7, R 5. N
ACSL
2007 - 2008 American Computer Science League Contest #4
Intermediate Division
Trees

TEST DATA

TEST INPUT TEST OUTPUT

1. BALTIMORE, 3, L 1. I
2. MARYLAND, 4, R 2. NONE
3. THIRTYYEARS, 9, L 3. NONE
4. MARRIOTTSRIDGE, 4, L 4. O
5. BINARYSEARCHTREE, 5, R 5. Y

You might also like