Question 1: Given a binary tree and an integer targetSum, return true if the tree has...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 1: Given a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. Note: A leaf is a node with no children. Return false if there does not exist a root-to-left path that adds up to the targetSum. 1. Find the appropriate search strategy that was discussed in the class (heuristic, DFS, BFS etc) to traverse the input tree for the above problem statement. 2. Identify all the edge cases. (such as if the tree node is NULL or reached to the end of the tree.) 3. Explain the intuition behind why your search strategy is better than the other strategies that we discussed in class. 4. Highlight the root-to-leaf path that you achieved from your strategy. 5. Evaluate your strategy/solution based upon the dimensions discussed in the class. MIS 429 Artificial Intelligence Assignment 1 a. Completeness b. Time and space complexity c. Optimality 6. Submit a PDF copy of your solution. 2 1- An example that outputs TRUE for the problem statement: Given the following tree and targetSum=25, your search algorithm should return TRUE. H 5 6 5 Explanation: The path 17611 gives us the target sum 25. Hence, the algorithm returns true. 2- An example that outputs FALSE for the problem statement: Given the following tree and targetSum=14, your search algorithm should return FALSE. Explanation: The path 17 sums up to 8. The path 1-9 sums up to 10. The path 719 or 917 sums up to 17. Hence, in no way we can get target sum 14. So the algorithm returns false. # 1 9 Question 1: Given a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. Note: A leaf is a node with no children. Return false if there does not exist a root-to-left path that adds up to the targetSum. 1. Find the appropriate search strategy that was discussed in the class (heuristic, DFS, BFS etc) to traverse the input tree for the above problem statement. 2. Identify all the edge cases. (such as if the tree node is NULL or reached to the end of the tree.) 3. Explain the intuition behind why your search strategy is better than the other strategies that we discussed in class. 4. Highlight the root-to-leaf path that you achieved from your strategy. 5. Evaluate your strategy/solution based upon the dimensions discussed in the class. MIS 429 Artificial Intelligence Assignment 1 a. Completeness b. Time and space complexity c. Optimality 6. Submit a PDF copy of your solution. 2 1- An example that outputs TRUE for the problem statement: Given the following tree and targetSum=25, your search algorithm should return TRUE. H 5 6 5 Explanation: The path 17611 gives us the target sum 25. Hence, the algorithm returns true. 2- An example that outputs FALSE for the problem statement: Given the following tree and targetSum=14, your search algorithm should return FALSE. Explanation: The path 17 sums up to 8. The path 1-9 sums up to 10. The path 719 or 917 sums up to 17. Hence, in no way we can get target sum 14. So the algorithm returns false. # 1 9
Expert Answer:
Answer rating: 100% (QA)
Solutions Step 1 1 The appropriate search strategy for this problem is a DepthFirst Search DFS algorithm DFS is a tree traversal algorithm that explores as far as possible along each branch before bac... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
The rigid link is supported by a pin at A, a steel wire BC having an unstretched length of 200 mm and cross- sectional area of 22.5 mm, and a short aluminum block having an unloaded length of 50 mm...
-
This program makes a binary tree and manipulates it using many different methods. I just need help implementing a preorder or postorder traversal on my binary tree for my isSame() method to make sure...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The first quarter of 2008 had not yet ended and Steve Savage already knew the company would surpass the projected $22 million in revenues for the year. He and the management team had doubled sales...
-
The water in a tank is pressurized by air, and the pressure is measured by a multi fluid manometer as shown in Fig. P142 Determine the gage pressure of air in the tank if h1 = 0.2 m, h2 = 0.3 m, and...
-
Find the piecewise-linear equivalent circuit for the diode of Fig. 1.15. Use a straight-line segment that intersects the horizontal axis at 0.7 V and best approximates the curve for the region...
-
A rectangular sharp-crested weir is used to measure the flowrate in a channel of width \(10 \mathrm{ft}\). It is desired to have the upstream channel flow depth be \(6 \mathrm{ft}\) when the flowrate...
-
On January 1, 2010, the ledger of Mane Company contains the following liability accounts. Accounts Payable ........ $52,000 Sales Taxes Payable ..... 7,700 Unearned Service Revenue ... 16,000 During...
-
a) Explain how considering aspects of Maslow's Hierarchy in the training and development program can help employees to be more engaged and productive at the organization. b) Offer a point on how...
-
The data in Table 6E.3 represent the results of inspecting all units of a personal computer produced for the past 10 days. Does the process appear to be in control? Inspected Nonconforming Fraction...
-
Valeant Pharmaceuticals (VRX) has 187m shares outstanding, $26.7 billion in debt and $807m in cash. It projects free cash flows for next 2 years based on earnings forecasts below, a marginal tax rate...
-
Marcy has a total of 100 dimes and quarters. If the total value of the coins is $14.05, how many quarters does she have?
-
Based upon your calculations from Problem Set 1, provide a brief discussion of how Boston Scientific's ROE has changed over the three years. Using the information from the financial statements,...
-
"In the context of a software project called 'ABC,' there is a requirement for 600 points of work categorized as 'TYPE 1' and 800 points of work categorized as 'TYPE 2.' Looking at the historical...
-
Dave's Fish Market (DFM) is open 12 months of the year. At DFM, the demand for fish is a very consistent 500 pounds per month. DFM orders the fish from a distributor in British Columbia at an...
-
This is a group project for analysis of the procurement and risk management aspects of a selected case study. See details under "Course Content." This is a case study developed for this class. It...
-
Using the following information, what is the cost to lease a car? . Security deposit Monthly lease payment Opportunity cost of security deposit End-of-lease charges $480 $480 per month for a...
-
6 (a) Briefly develop a mathematical model of the behaviour of a copper-twisted pair cable (b) Derive the magnetic energy from: w given that: K + w, where the - - k symbols have their usual meaning...
-
Argue that for any constant 0 < 1/2, the probability is approximately 1 - 2 that on a random input array, PARTITION produces a split more balanced than 1 to .
-
Professor Pinocchio claims that the height of an n-node Fibonacci heap is O(lg n). Show that the professor is mistaken by exhibiting, for any positive integer n, a sequence of Fibonacci-heap...
-
A Toeplitz matrix is an n n matrix A = (a ij ) such that a ij = a i - 1 . j - 1 for i = 2, 3, . . . , n and j = 2, 3 , . . . , n. a. Is the sum of two Toeplitz matrices necessarily Toeplitz? What...
-
Do the assumptions for Bernoulli trials appear to hold? Explain. If the assumptions hold, identify success and the probability of interest. (a) A TV ratings company will use their electronic...
-
Use Table 1, or software, to find (a) \(B(8 ; 16,0.40)\); (b) \(b(8 ; 16,0.40)\); (c) \(B(9 ; 12,0.60)\); (d) \(b(9 ; 12,0.60)\); (e) \(\sum_{k=6}^{20} b(k ; 20,0.15)\); (f) \(\sum_{k=6}^{9} b(k ;...
-
Use Table 1, or software, to find (a) \(B(7 ; 18,0.45)\); (b) \(b(7 ; 18,0.45)\); (c) \(B(8 ; 11,0.95)\); (d) \(b(8 ; 11,0.95)\); (e) \(\sum_{k=4}^{11} b(k ; 11,0.35)\); (f) \(\sum_{k=2}^{4} b(k ;...
Study smarter with the SolutionInn App