Language C++ 12 40 1 > #includ 30 31 int is 32 33 The 34 35 36 37 38 39 */ 40 } 41 42 > int ma NU 1 13 23 Nil The tre- 5
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Language C++ 12 40 1 > #includ 30 31 int is 32 33 The 34 35 36 37 38 39 */ 40 } 41 42 > int ma NU 1 13 23 Nil The tre- 5
Language C++ 12 40 1 > #includ 30 31 int is 32 33 The 34 35 36 37 38 39 */ 40 } 41 42 > int ma NU 1 13 23 Nil The tre- 5 assembled as described in Input ut for Custom Testing by the provided code >tub. Nodes marked "Nil" have no value and are placeholders to make left and right clear. • Search for val[0] = 30. Start from the root of a tree. 30 > 20: Search in the right subtree which has the root = 30. The item is found, return 1. • Search for val[1] = 10. Start from the root of a tree. 10 < 20 : Search in the left subtree which has the root = 10. The item is found, return 1. • Search for val[2] = 12. Start from the root of a tree. 12 < 20 : Search in the left subtree which has the root = 10.12 > 10: Search in the right subtree which has the root = 12. The item is found, return 1. • Search for val[3] = 15. Start from the root of a tree. 15 <20: Search in the left subtree which has the root = 10. 15 > 10: Search in the right subtree which has the root = 12. 15 > 12: Search in the right subtree which has the root = 13. End of the tree and the item is not found, return 0. • The return values are [1, 1, 1, 0]