HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN303 2013-15 Questions > problem:


14-Fall1-30. 50771 - BST Level Sum

CEN303 2013-15 Questions

Start: Dec.15.2013 at 02:00:00 PM
Finish: Dec.15.2013 at 07:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 50531 - File Decryption
• 50464 - From Tirana to Durres
• 13-Fall2-10. 50411 - Sum of the Lea...
• 13-Fall2-20. 50687 - Pascal Triangle - 2
• 13-Fall2-40. 50753 - Average of the...
• 13-Fall2-50. 50686 - The Container
• 14-Fall1-10. 50740 - Service Time - 1
• 14-Fall1-20. 50750 - Service Time - 2
• 14-Fall1-30. 50771 - BST Level ...
• 14-Fall1-40. 50683 - Parking Buses
• 14-Fall1-50. 50770 - Average Depth
• 14-Fall1-60. 50784 - Top Growing C...
• 14-Fall2-10. 50751 - The biggest Mi...
• 14-Fall2-20. 50794 - Writing Files Int...
• 14-Fall2-30. 50490 - Across the River
• 14-Fall2-40. 50772 - The Path of a N...
• 14-Fall2-50. 50681 - Center of a Series

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.

BST Level Sum

Question: Mr. Uka is having a research. On his research, he is using Binary Search Trees. And, he has to calculate the sum of the nodes in the given level.

For some reason, the tree can grow very deep, and, this causes problems. Thus, he wants to limit the depth to a certain value. The nodes which go deeper than the given limit will be ignored.

Write a program that is going to read the given list of values, and insert them into the BST. And calculate the sum of the nodes in the given level.

Input specification: In the first line, you will be given three integers:

  • max depth: an integer between 0 and 15
  • Sum level: the level to calculate the sum of the numbers, an integer between 0 and 15
  • n: the number of the elements in the following line to insert into BST; an integer between 0 and 50000

Output specification
Show sum of the numbers in the given level.
Note: If there exists a number in BST, the number will be ignored.

 Sample Input I     Sample Output I   
 2 1 10
 6 2 4 8 5 2 3 7 4 1
 10

Sum of the elements in level 1 is (8+2) 10
Для отправки решений необходимо выполнить вход.

www.contester.ru