Lab Dynamic Programming
Lab Dynamic Programming
Q1. In modern industrial applications, such as computer graphics and scientific computing,
the efficiency of matrix operations is crucial for rendering high-resolution images or
processing large datasets. These operations often involve multiplying a series of matrices. For
example, in computer graphics, various transformations like scaling, rotation, and translation
are represented as matrices. To optimize the performance of these operations, it is necessary
to compute the product of matrices in an order that minimizes the computational cost. Write
a C program using dynamic programming to solve the Matrix Chain Multiplication problem.
Your program should:
o Transformation 1: 100x10
o Transformation 2: 10x50
o Transformation 3: 50x20
o Transformation 4: 20x5
Q2. In the field of bioinformatics, comparing DNA sequences is a crucial task for identifying
similarities between species, detecting mutations, and understanding evolutionary
relationships. DNA sequences can be represented as strings consisting of characters from the
set {A, C, G, T}. One of the common ways to compare two DNA sequences is by finding the
Longest Common Subsequence (LCS), which identifies the longest sequence of characters
that appear in both DNA strings in the same relative order (but not necessarily
consecutively). Write a C program using dynamic programming to solve the LCS problem for
the maximum DNA sub-sequence matching.
Q3. In real-time applications, such as database query optimization or compiler design, the
frequency of accessing certain data elements is not uniform. For example, in a database, some
records may be searched more frequently than others. An Optimal Binary Search Tree
(OBST) can minimize the average time required to access records based on their frequencies
of access. The OBST problem involves constructing a binary search tree that minimizes the
cost of search operations when probabilities (or frequencies) of accessing elements are
known.
Write a C program using dynamic programming to solve the Optimal Binary Search Tree
(OBST) problem. Your program should:
Take as input an array of keys (sorted in increasing order) and an array of their
corresponding access probabilities (or frequencies).
Compute the minimum search cost for constructing the binary search tree.
Display the structure of the OBST (indicating which key should be the root, left child,
and right child at each level).
Test your program with the following keys and their access frequencies:
Keys: {10, 12, 20}
Frequencies: {34, 8, 50}