Tree = 1 / \ 2 3 / / 4 6 target = 7 answer = false Naive Solution Tree = 1 / \ 2 3 / / \ 4 6 7 target = 6 answer = true 1 ≤ n ≤ 100,000 where n is the number of nodes in root.Given that the root was originally a complete binary tree whose values were labeled as described above, and that some of the subtrees were deleted, return whether target exists in root. You are given a binary tree root and an integer target. In general, nodes' values are labeled 1 to n in level order traversal. The root has a value of 1, its left child is 2 and its right child is 3. Finding an Element from a Complete Binary Tree | Creative Commons License ProblemĬonsider a Complete Binary Tree of n nodes whose values are 1 to n.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |