17 Problemreduction
17 Problemreduction
Example:
12 = 2 . 2 . 3
15 = 3. 5
lcm(12, 15) = (3) . 2 . 2 . 5 = 60
Example:
24 = 2 . 2 . 2 . 3
60 = 2 . 2 . 3 . 5
lcm(24, 60) = (2 . 2 . 3) . 2 . 5 = 120
https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/
Example 2:
Counting paths between two vertices in a graph
Note:
Note:
Note:
Mathematical model:
Let x, y, and z be the amounts (in millions of dollars) invested
in stocks, bonds, and cash, respectively. Then the optimization
problem is:
Applications of Linear Programming (LP):
Solution:
Inspired by Heapsort!!
Now, the company wishes to maximize its profit. How many units
of A and B should it produce respectively?
Profit: Maximize Z = 6X+5Y
Subject to:
X+Y ≤ 5
3X+2Y ≤ 12
X≥0 & Y≥0
Puzzle
• You have 11, 8 and 5 litre milk container.
• Each container has no markings except for that which gives
you it's total volume.
• You have a 12 litre container full of milk.
• You must use the containers in such away as to exactly
measure out 4 litre of milk.