30 Day code challenge-python
Day 23—BST Level-Order Traversal
Task
A level-order traversal, also known as a breadth-first search, visits each level of a tree’s nodes from left to right, top to bottom. You are given a pointer, root, pointing to the root of a binary search tree. Complete the levelOrder function provided in your editor so that it prints the level-order traversal of the binary search tree.
Input Format
The first line contains an integer, T(the number of test cases).
The T subsequent lines each contain an integer, data, denoting the value of an element that must be added to the BST.
Output Format
Print the data value of each node in the tree’s level-order traversal as a single line of N space-separated integers.
Explanation
Line 31–36: Gets input from the data and calls the class function insert.
Line 7–18: Inserts value to the tree
Line 20–30: Checks the values in each level
Line 37: Calls the levelOrder function and prints the value.
See you on day 24