Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me to write this program in python, which take the input and return output like above mplement binary search tree for integers. There
please help me to write this program in python, which take the input and return output like above
mplement binary search tree for integers. There is a file "VSTUP.TXT" containing lines with commands. Every command s on separate line. Read command must be copied to standard output. The commands are: - P - Print the structure; every level of the tree is indented by two spaces in comparison to the level above, initial indentation is 0 ; the subtree with lower values is printed first, than with the higher ones. Each item is printed on a separate line. - I- Insert item; behind the instruction (letter I) is a space and then the value to be inserted; after insertion it should be reported on a separate line "Prvek vlozen" (if the insertion was successfull), or "Prvek uz ve strome byl" (if the item has been in the tree before). - D - Delete the item; behind the instruction (letter D) is a space and then the value to be deleted; after deletion it should be on a separate line reported "Prvek vypusten" (when really deleted), or "Prvek ve strome nebyl" (when the item has not been in the structure). When deleting an item having two ancestors it should be used the smallest from the bigger ones. Program prints on standard output. Sample input: Sample input: I 10 I 20 I 15 I 20 P D 10 P Sample outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started