Computing Ancestors of # for Stern-Brocot Tree Reading about the Stern-Brocot tree, the article gives this example:

using 7/5 as an example, its closest smaller ancestor is 4/3, so its left child is (4 + 7)/(3 + 5) = 11/8, and its closest larger ancestor is 3/2, so its right child is (7 + 3)/(5 + 2) = 10/7.

Getting the left and right children seem clear to me:


*

*left - mediant of # (7/5) and closest smaller ancestor (4/3)

*right- mediant of # (7/5) and closest larger  ancestor (3/2)


But, how can I figure out the closest smaller and larger ancestors of 7/5?

"But, how can I figure out the closest smaller and larger ancestors of 7/5?"
Here is a method using a version of the subtractive Euclidean algorithm:
A    :   7 (1) - 5 (0) =  7
B : 7 (0) - 5 (1) = -5
C : 7 (1) - 5 (1) =  2   A + B
D : 7 (1) - 5 (2) = -3   B + C  Adding smallest positive to 'smallest' (lowest absolute value) negative result
E : 7 (2) - 5 (3) = -1   D + E  Repeating above procedure
F : 7 (3) - 5 (4) =  1   C + E
G : 7 (5) - 5 (7) =  0   E + F
At each stage the smallest positive and 'smallest' (i.e. closest-to-zero, smallest absolute value) results are added.
The bracketed coefficients at each stage represent convergent fractions.
The coefficients of the equations with equal and smallest positive and negative results (E and F) represent the Bezout identity and are the 'parents' in the Stern Brocot tree.  The result of these equations being |1|, 1 is the greatest common divisor of 7 and 5.  So the 'parents' are $\frac{3}{4}$ and $\frac{2}{3}$ .  They are the two fractions of which $\frac{5}{7}$ is the mediant.
Disregarding A and B - which are the 'set-up' for the algorithm - the positive and negative results are in a sequence of one positive, two negative, one positive and zero. The interpretation of this 'flipping' is that the continued fraction of $\frac{5}{7}$  is [0; 1, 2, 1, 1] or (which is the same thing) [0; 1, 2, 2].
A longer discussion of this adaptation of the subtractive Euclidean algorithm is here: https://simplyfractions.blogspot.com/p/blog-page_5.html
