Commutativity is a fundamental property in mathematics where the order of operands in a binary operation does not affect the…