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 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 animalset leftNone, rightNone:
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 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, egTrue means that all of the
animals you are searching for can be found in a node that is in depth 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 ie smallest
depth value
Constraints:
The tree can contain to nodes.
The root node has a depth of
Your code must utilize the OceanNode object as shown above.
Your code must complete within seconds. Otherwise, the test case is considered a failure.
You cannot import any library for this assignment.
The animal set can have to animals.
Your function name must be oceanexplore all lower case and the two words must be
separated by an underscore
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
