I mean I want to make a BST tree by few nodes which each of that has a frequency so I want to implement a BST tree has been built by current nodes ,
the low frequency nodes must be left child of parent codes and vice versa and it start with the highest frequency . The calculation must be the lowest one created by nodes in tree.
For example:
Node 1 : 0.9
Node 2: 0.4 The calculation must be the lowest one created by nodes: 1 * 0.9 + 2 * 0.6 + 3 * 0.1= 2.4
Node 3: 0.1
Node 1
Node 2
Node 3