CGPT 2
CGPT 2
1. Knapsack Problem:
Scenario: Imagine you have a knapsack with a limited weight capacity,
and you want to maximize the total value of items you can carry.
Approach: Greedily select items based on their value-to-weight ratio
until the knapsack is full.
2. Job Sequencing with Deadlines:
Scenario: You have multiple jobs with associated deadlines and profits.
You need to schedule these jobs to maximize the total profit.
Approach: Sort jobs by their profits and schedule them in a way that
doesn't miss any deadlines.
3. Optimal Merge Patterns:
Scenario: Given a set of files with different sizes, you want to merge
them efficiently.
Approach: Greedily merge the smallest available files at each step to
minimize the overall merging cost.
4. Huffman Coding:
Scenario: You want to encode a set of characters efficiently to
minimize the total encoded length.
Approach: Build a Huffman Tree by repeatedly combining the two
least frequent characters until a single tree is formed.
Dynamic Programming:
1. Multistage Graph:
Scenario: Represent a process with multiple stages, each with different
costs. Find the optimal path through these stages.
Approach: Use dynamic programming to find the minimum cost path
through the stages.
2. All Pairs Shortest Paths:
Scenario: Find the shortest paths between all pairs of vertices in a
graph.
Approach: Utilize dynamic programming to compute the shortest
paths step by step.
3. 0-1 Knapsack:
Scenario: Similar to the Knapsack Problem, but now you can't take
fractions of items.
Approach: Use dynamic programming to fill a table with the maximum
value achievable at each subcapacity.
4. Chained Matrix Multiplication:
Scenario: Given a sequence of matrices, find the most efficient way to
multiply them.
Approach: Dynamic programming is used to minimize the total
number of scalar multiplications.
5. Longest Common Subsequence:
Scenario: Find the longest subsequence present in two given
sequences.
Approach: Dynamic programming is employed to build a table of
lengths of common subsequences.
6. Travelling Salesperson Problem:
Scenario: A salesperson wants to visit each city exactly once and return
to the starting city with the minimum possible total distance traveled.
Approach: Dynamic programming techniques can be applied to find
the optimal tour.