If we assume that n1 and n2, for which we have to find LCA, exists in the tree, then the above problem can be solved in a single traversal.
ຖ້າພວກເຮົາສົມມຸດວ່າ n1 ແລະ n2, ເຊິ່ງພວກເຮົາຕ້ອງຊອກຫາ LCA, ມີຢູ່ໃນຕົ້ນໄມ້, ບັນຫາຂ້າງເທິງນີ້ສາມາດແກ້ໄຂໄດ້ໃນທາງດຽວ.