Question: Part A A tree is a graph that has no cycles. Discuss, as a class, the special properties of trees that are Binary Search Trees,
Part A A tree is a graph that has no cycles. Discuss, as a class, the special properties of trees that are Binary Search Trees, or BST Write an algorithm for inserting an element into a BST. Use your algorithm to insert the following items (in the order they are listed into the BST: goat, dog, frog, elephant, rhino, sheep, ant, zebra. Complete the following table: Item Root Node (YES/NO) Leaf Node (YES/NO) List of children (if Parent Node) dog elephant frog goat rhino sheep zebra Part B Write an algorithm to search for an item in a BST. Your algorithm should take as input the BST and the target item. It should return true if the item is in the BST and false otherwise 1. How many nodes in the BST do you need to visit when searching for "dog" in the BST in Task 17 2. How many nodess in the BST do you need to visit when searching for "cont" in the BST in Task 1? 3. How many nodes in the BST do you need to visit when searching for "monkey" in the BST in Tusk 17 4. What is the maximum number of nodes you would need to visit when searching for an item in this BST 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
