Feature #9: Recreating the Decision Tree
Implement the "Recreating Decision Tree" feature for our "Facebook" project.
We'll cover the following
Description
Facebook uses a recommendation system to recommend ads to its users. This recommendation system recommends ads on the basis of the results obtained from this decision tree. Facebook wants to implement this recommendation system for Instagram users as well. For this purpose, Facebook wants to replicate the decision tree from a Facebook server to an Instagram server.
The decision tree used in Facebook’s recommendation server is serialized in the form of its inorder and preorder traversals as strings. Using these traversals, we need to create a decision tree for Instagram’s recommendation system.
Let us say we have these preorder and inorder traversals respectively: ["subject", "viewed", "likeable", "notlikeable", "notviewed", "similar", "nonsimilar"]
and ["likeable", "viewed", "notlikeable, "subject", "similar", "notviewed", "nonsimilar" ]
. The decision tree for these traversals is shown in the illustration below:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.