Give the fraction of permutations of the keys $A $ through $G$ that will, when inserted into an initially empty tree, produce the same Binary search tree as does $A$ $E$ $F$ $G$ $B$ $D$ $C$
ANSWER:
(5 C 2) /7! = 10/5040 = 1/504.
Anyone has a clue on how we came up with this answer?

When you have a given binary search tree, the possible insertion sequences that will produce that tree is exactly every sequence where an internal node comes before all of its descendants in the tree.
So in this case, the sequence must start with
A E,Fmust come beforeG, andB,D,Coccur in that order between themselves.But we're free to choose how we merge the sublists
F GandB C Dto produce the final sequence. Once we have written downA E, we can choose any $2$ of the remaining $5$ positions to beFandG, and the last three then becomeB,DandC, in that order.Therefore there are $\binom52=10$ different input sequences that produce your given tree.