HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50772 - The Path of a Node

Guest
• Review clarifications (1)

Volume problems

• 50840 - Tanker trucks
• 50877 - Friendly Queue
• 50876 - He is my cousin
• 50997 - Dynamic Knights
• 50490 - Across the River
• 50816 - Largest Sum Path
• 50857 - Nine-Stones Game
• 50837 - Sum is equal to K
• 50772 - The Path of a Node
• 50936 - Saving the Soldiers
• 50447 - Swimming Contest - 2
• 50828 - Arranging Time Table
• 50794 - Writing Files Into HDD
• 50929 - Present from your uncles
• 50863 - Total Access Cost of a BST
• 50979 - Minimum access cost for BST
• 51000 - Book Index

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

The Path of a Node

Question: You will be given a series of integers. And, you are asked to place them into a binary search tree. Write a program that is going to show the path to a given node by using characters:

  • "S" for start (or the root),
  • "L" for left, or
  • "R" for right

Input specification
In the first line you will be given two integers (n and num). Then in the following lines you will be given n integers where the numbers are between -20000 and +20000 and n is between 1 and 40000.
Note: There are at most 25 numbers in every line and the numbers are separated by space.

Output specification
If the searching number exists in the tree, show the path to the node given by num. Otherwise, show the message "Not in the list"

Sample Input I
6 6
4 7 3 2 6 3
Sample Input II
6 9
4 7 3 2 6 3
Sample Output I
SRL
Sample Output II
Not in the list


Для отправки решений необходимо выполнить вход.

www.contester.ru