Question: please do it fast any program language Question 2 Revisit Later How to Attempt? Cryptic tree Sherlock received a strange case that had an interesting


Question 2 Revisit Later How to Attempt? Cryptic tree Sherlock received a strange case that had an interesting twist The murderer had placed the victim's body on the top of a tree. The tree was a special one with its roots at the top and leaves at the bottom. As any crime is not perfect, this murderer had left a series of clues in the leaves and the nodes of the tree. The clues were a series of numbers present at the leaves and nodes starting from the bottommost leaves and moving up one by one and Shelock has to find them and crack them in order to solve the crime. You have to help Sherlock crack the puzzle. You are given the set of numbers, but in two of the following different ways: 1. Such that the root is between its children 2. Such that the root is before its children Input Specification: input1: The number array representing the values in the 1 st way input2: The number array representing the values in the 2nd way input3: Size of the array Note: In the case where the body is not on the tree, the tree can be empty too. Output Specification: The array giving the correct sequence of numbers as desired for solving the puzzle. input1: {4,2,5,1,3) input2: {1,2,4,5,3) input3: 5 Output: (4,5,2,3,1) Explanation: and the traversal according to the question will be {4,5,2,3,1). Example 2: input1: (2,3,5,1,6) input2: {1,3,2,5,6) input3:5 Output:
Step by Step Solution
There are 3 Steps involved in it
To solve the problem were essentially tasked with reconstructing a binary tree given its inorder and preorder traversals and then obtaining the postor... View full answer
Get step-by-step solutions from verified subject matter experts
