1. (30 pts) Given a string representing the root of a binary tree (NOTE: Not a BST, there is no sort order) and an integer, return whether or not there is a root-to-leaf path such that adding up all the values along the path equals the integer. Output a 1 if the result is true, and a 0 if the result is false. You must use a Binary Tree implementation (NO STL) for the input to receive credit. Feel free to include any variables you will need in your functions. Case 1: Input 1: 1 2 3 Output 1: 1 3 Case 2: Input 2: 6 7 8 27139 null 1 4 null null null 5 Output 2: 0 20 Case 3: Input 3: 5 4 8 11 null 13 4 72 null null null1 Output 3: 1 22 Assumptions: The given strings will contain no more than 50 inputs. The given input starts at the root and builds the tree sequentially from left to right, as shown below "null" represents an empty space in a given level. The integer to be checked is located on a separate line from the binary tree, and thus can be read in another input or as a separate line in a file. You may use cin/cout or input/output files for submission.
1. (30 pts) Given a string representing the root of a binary tree (NOTE: Not a BST, there is no sort order) and an integer, return whether or not there is a root-to-leaf path such that adding up all the values along the path equals the integer. Output a 1 if the result is true, and a 0 if the result is false. You must use a Binary Tree implementation (NO STL) for the input to receive credit. Feel free to include any variables you will need in your functions. Case 1: Input 1: 1 2 3 Output 1: 1 3 Case 2: Input 2: 6 7 8 27139 null 1 4 null null null 5 Output 2: 0 20 Case 3: Input 3: 5 4 8 11 null 13 4 72 null null null1 Output 3: 1 22 Assumptions: The given strings will contain no more than 50 inputs. The given input starts at the root and builds the tree sequentially from left to right, as shown below "null" represents an empty space in a given level. The integer to be checked is located on a separate line from the binary tree, and thus can be read in another input or as a separate line in a file. You may use cin/cout or input/output files for submission.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Need help with this
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education