OA. free
Free
MathWorks Data Structures & Algorithms Data Structures & Algorithms Medium

37.

MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

(Coding) Reduced Fraction Sums

Consider two fractions in the form a/b and c/d, where a, b, c, and d are integers. Given a string describing an arithmetic expression that sums these two fractions in the format a/b+c/d, compute the sum and fully reduce the resulting fraction (i.e., e/n, then save the reduced fraction as a string in the form e/f. For example:

  • The expression 1/2+1/6 evaluates to 4/6, which we reduce to the string 2/3.
  • The expression 7/10+13/10 evaluates to 20/10, which we reduce to the string 2/1.

Complete the function in the editor. It has one parameter:

Name Type Description
expressions string array An array of arithmetic expressions in the form a/b+c/d.

The function must return an array of strings where each index i contains the fully reduced form of the fraction that resulted from evaluating expressions. Note that each fraction must be fully reduced to pass this challenge.

Input Format

The first line contains an integer, n, denoting the number of strings in expressions.
Each of the n subsequent lines contains a string in the form a/b+c/d describing expressions.

Constraints

  • 1 ≤ n ≤ 500
  • 1 ≤ a, b, c, d ≤ 2000

Output Format

Return an array of strings where each index i contains the fully reduced form of the fraction that resulted from evaluating expressions.

Sample Input 0

2
1/2+1/6
7/10+13/10

: Hello World

  1. (Python Question) Hello World

What is the output when the following code is executed?

str1="helloworld"
str1[::-1]

Pick ONE option

Choose one option.
Show answer & explanation
Answer: A. A) dlrowolleh

Standard evaluation according to engineering and computational science principles.

Step-by-step Derivation:
Step 1: Analyze problem specification.
Step 2: Derive theoretical solution.
Step 3: Select corresponding answer option.