= minimum cost for keys to . Choose key as root. Left subtree: . Right subtree: . All keys go one level deeper. The sum adds depth cost for all keys in the range.
Work through examples by hand before coding. Understanding the pattern makes implementation simple. Practice with similar problems to reinforce your understanding.