Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the
You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the program is important so it is best to use an algorithm in the code which will not timeout
Goldilocks Treasure Islands Problem Submissions Leaderboard Discussions Contest ends in 5 days Captain Pi has hidden his treasures among an archipelago of n islands. Instead of drawing a map to his treasure islands though, he has left a series of clues for himself on several islands, only some of which actually contain any treasure. Each clue contains a number and up to two references to other islands. He has a secret number, s, which serves as the key to finding the treasures in the islands. Starting with the first clue, whenever the sequence of numbers on a chain clues sum to a multiple of s, then that island contains treasure Submissions: 6 Max Score: 25 Difficulty: Medium Rate This Challenge: More E D E H 6 For example, the diagram shows where the treasures would be located if 8 = 7 and the clues made references as shown. The first clue on island A has the number 2 and references islands B and C as follow-up islands. Since the clue on island B has the value 5 and 2+5 is divisible by 7, that means that there is treasure on island B. Goldilocks has figured out Captain Pi's scheme, but she is a lazy pirate (and thief) and won't go after all of the treasure. If the number of treasure-containing islands on any path of islands is fewer than lor more than h, she is not interested in it (either not worth it, or too much work). Given the complete set of clues (starting from island #1), the secret s, and the values of 1 and h, find the number of paths that would interest Goldilocks. In this problem, a tree will be constructed from the input for you, but in order for that given code to work, you must first complete the ADT for binary trees that was started, but left incomplete. Input Format The first line contains four integers, separated by a space, in the format: nslh The next n lines contains 4 integers: &, v kto indicate that the clue on island has the number and makes reference to islands numbered j and k. If either jor kis 0, then no reference in that position was made by that clue. Constraints 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started