Question: Problem Statement: You are an ocean explorer designing an application that will help you find animals under the sea. Your application will take in as

Problem Statement:
You are an ocean explorer designing an application that will help you find animals under the sea. Your
application will take in as inputs the 2-D layout of the undersea area of where you plan to explore, the
animals you're searching for, and the depth you want to search.
The layout of the area will be in the form of a binary tree. Each node of the binary tree must be
represented by the following object:
class OceanNode:
def (self, animal=set(), left=None, right=None):
self.animal = animal
self.left = left
self.right = right
The animal attribute represents an animal or animals typically present in a particular point in the ocean,
the OceanNode object represents that point in the ocean. The animal data type is a set and it may be
empty.
Your program should return whether the animal or animals you're looking for are present in the binary
tree and the depth of the node to which all of those animals can be found.
If all of the animals you're searching for cannot be found in a particular node, then your program should
return (False,0). If a node in your tree has all of the animals you're looking for (lets call it a found node),
then your program should return True and that found node's depth, e.g.(True,3) means that all of the
animals you are searching for can be found in a node that is in depth 3 of the binary tree.
If a node only contains some of the animals you're searching for, then that does not count as a found
node.
If there is more than one found node, then priority should be given to the shallowest depth (i.e. smallest
depth value).
Constraints:
The tree can contain 1 to 100 nodes.
The root node has a depth of 0.
Your code must utilize the OceanNode object as shown above.
Your code must complete within 2 seconds. Otherwise, the test case is considered a failure.
You cannot import any library for this assignment.
The animal set can have 0 to 5 animals.
Your function name must be ocean_explore (all lower case and the two words must be
separated by an underscore).
Problem Statement: You are an ocean explorer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!