Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Calculating possible combinations from elements of a binary tree

$
0
0

As an example, here is a list of elements/products forming a (very hypothetical) tree, the available numbers for each element, and an example of what a possible tree would look like. The numbers are always the same: one of each child element produces one parent element (e.g. 1 Oil + 1 Fuel = 1 Plastic).

Ressources

Tree

I want to calculate the maximum number of combinations of any two elements of this tree. But not necessarily the root nodes (Computer and Smartphone in the example), also any other combination of two resources/elements that are lower level in the hierarchy. For example how many combinations of 1 Alloy and 1 Plastic can the above elements/resources produce.

I tried to scale each element back to their node sources, but wasn't sure how to factor in the already available elements that are higher in the hierarchy.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>