English, asked by muskanmaheshwari9988, 6 months ago

Question: 2
A tree is considered special if the sums of all the nodes at each level are in an Arithmetic Progression (AP).
Given the root note of a binary tree. Return an array representing the minimum number that can be added at each level to make that tree special.
Input:
3
2 7
1
15
Output: [0, 0, 0]
Input:
17
12
Output: [0, 0,3]
Input:
Dhea ANSWER​

Answers

Answered by anshuljha698
2

Answer:

Mean Diff will always be root -(root left+root right ). now the this will remain constant. so at every level we will have the idea number that will make it a special tree. We subtract the actual given number from the ideal required number and print it . boom you get an array

Attachments:
Answered by shilpa85475
0

A tree is considered special when the numbers of all the nodes at each level are in the Arithmetic Progression (AP) and the root note of the binary tree. Special input is:

  • In computer science, a binary tree is a tree data structure where each node has at least two children, referred to as the left child and the right child.
  • Repeated definition using the theory of newly established theory that (empty) binary tree is a tuple (L, S, R), where L and R, are binary trees or an empty set and S is a singleton set containing a root.
  • Some authors allow the binary tree to be an empty set as well.
  • You are given the root of an n-tree with n-nodes where each node in the tree has a node.
  • Val coins Val.
  • As a combination, we can divide the same members into two equal parts and repeatedly find the minimum of those parts.
  • Next, compare the minimum of those components to get the minimum number of all the same members.
  • Solution Steps Write a repetition task that receives the list and its starting and ending index as par-metres.
Similar questions