Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a c progamme plsss A binary tree can be uniquely represented in the following way. For example, given the trees [ 1 2 3

write a c progamme plsss
A binary tree can be uniquely represented in the following way. For example, given the trees
[1234],[123##4],[12345###6], and[-123##45####678########## 10]:
10
Now you are asked to return the maximum path sum of a binary tree.
Input The first line is an integer N(2N100), the number of test cases. For each test
case, it contains a binary tree, where the total number of node tokens is smaller than
Each token is separated by a space and there is no space after the last token. You
may also assume that each node of the tree is labeled by an integer between -104 and
104.
Output The maximum sum of the node values in a root-to-leaf path.
Sample Input
3
1,2,3,4
123 # # 4
12345 # # # 6
Sample Output
Explanation Case1: it has two paths: 1+2+4 v.s.1+3.
Case2: it has two paths: 1+2 v.s.1+3+4.
Case3: it has three paths: 1+2+4+6 v.s.1+2+5 v.s.1+3.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

ISBN: 0782125395, 9780782125399

More Books

Students also viewed these Databases questions