We consider the following problem: what is the most general Lie algebra or superalgebra satisfying a given set of Lie polynomial equations?The presentation of Lie (super)algebras by a finite set of generators and defining relations is one of the most general mathematical and algorithmic schemes of their analysis. That problem is of great practical importance covering applications ranging from mathematical physics to combinatorial algebra. Some particular applications are construction of prolongation algebras in the Wahlquist-Estabrook method for integrability analysis of nonlinear partial differential equations and investigation of Lie (super)algebras arising in different (super)symmetrical physical models. The finite presentations also indicate a way to q-quantize Lie (super)algebras.To solve this problem, one should perform a large volume of algebraic transformations which is sharply increased with growth of the number of generators and relations. For this reason one needs, in practice, to use a computer algebra tool. We describe here an algorithm for constructing the basis of a finitely presented Lie (super)algebra and its commutator table, and its implementation in C. Some computer results illustrating our algorithm and its actual implementation are also presented.