0% found this document useful (0 votes)
14 views

Lab Dynamic Programming

Uploaded by

Komal Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lab Dynamic Programming

Uploaded by

Komal Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Assignment (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:

 Accept as input the dimensions of matrices, where each matrix represents a


transformation (or computational operation) in an industrial process.
 Calculate the minimum number of scalar multiplications required to multiply the
matrices in an optimal order.
 Display the optimal parenthesization (order) for matrix multiplication that minimizes
the computation cost.
 Test your implementation with the following set of transformation matrices:

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.

 Accept two DNA sequences as input.


 Compute the length of the longest common subsequence between the two DNA
sequences.
 Display the actual LCS (the longest common subsequence).
 Test the program with the following sample DNA sequences:

o DNA Sequence 1: ACCGGTCGAGTGCGCGGAAGCCGGCCGAA


o DNA Sequence 2: GTCGTTCGGAATGCCGTTGCTCTGTAAA

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}

You might also like