I need an algorithm for the following problem:
There's a tree with N fruits each with its own weight w and height h. I can only reach a fruit if it's no taller than H inches. Also every time I pick a fruit, all the other fruits in the tree rise by exactly U inches. I need to find out the maximum amount (total weight) of fruits I can collect.
Slobodino 0 Newbie Poster
Recommended Answers
Jump to PostYou haven't given enough information to solve the problem, yet.
Jump to PostHave you tried to do anything yet, I'd like to help but I won't do you program from start to finish. It looks like it could be solved using a 0-1 knapsack with slight modification for the heights changing as you pick. If you post some code you're working/stuck on …
Jump to PostThe answer to the problem is to use minimax to select the best sequence (or alpha-beta if you prefer), and depth first search. Then you can find absolutely the best picking sequence, for any arrangement of fruit and heights.
Dynamic, shallow algorithms will generally approximate, but can't give, the …
All 9 Replies
Adak 419 Nearly a Posting Virtuoso
craig_ka 0 Newbie Poster
Slobodino 0 Newbie Poster
craig_ka 0 Newbie Poster
nezachem 616 Practically a Posting Shark
abhimanipal 91 Master Poster
Slobodino 0 Newbie Poster
Adak 419 Nearly a Posting Virtuoso
craig_ka 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.