We consider discrete best approximation problems in the setting of tropical algebra, which is concerned with the theory and application of algebraic systems with idempotent operations. Given a set of input--output pairs of an unknown function defined on a tropical semifield, the problem is to determine an approximating rational function formed by two Puiseux polynomials as numerator and denominator. With specified numbers of monomials in both polynomials, the approximation aims at evaluating the exponent and coefficient for each monomial in the polynomials to fit the rational function to the data in the sense of a tropical distance function. To solve the problem, we transform it into an approximation of a vector equation with unknown vectors on both sides, where one side corresponds to the numerator polynomial and the other side to the denominator. Each side involves a matrix with entries dependent on the unknown exponents, multiplied by the vector of unknown coefficients. We propose an algorithm that constructs a series of approximate solutions by alternately fixing one side of the equation to an already-found result and leaving the other side intact. Each equation obtained is approximated with respect to the vector of coefficients, which yields this vector and approximation error, both parameterized by exponents. The exponents are found by minimizing the error with an optimization procedure based on an agglomerative clustering technique. To illustrate, we present results for an approximation problem in terms of max-plus algebra (a real semifield with addition defined as maximum and multiplication as arithmetic addition), which corresponds to an ordinary problem of piecewise linear approximation of real functions. As our numerical experience shows, the proposed algorithm converges in a finite number of steps and provides a reasonably accurate solution to the problems considered.