Question

Give pseudocode that performs the traceback to construct an LCS from a filled dynamic programming table...

Give pseudocode that performs the traceback to construct an LCS from a filled dynamic programming table without using the “arrows”, in O(n + m) time.

2. Suppose we are given a “chain” of n nodes as shown below. Each node i is “neighbors” with the node to its left and the node to its right (if they exist). An independent set of these nodes is a subset of the nodes such that no two of the chosen nodes are neighbors. In the below example, the first and fourth vertices form an independent set, but the first, third, and fourth vertices do not (because the third and fourth are neighbors). Now suppose each node has a positive weight. We are interested in computing an independent set such that the sum of the weights of the chosen nodes are as large as possible. In the example, the optimal solution is to choose the second and fourth vertices for a weight of 30.

(15) - (20) - (7) - (10)

(a) A natural attempt of a greedy algorithm for this problem is to take the vertex with the largest weight, then delete that vertex’s neighbors (because they cannot also be in an independent set). Repeat this process until there are no more vertices which can be included. Give a counterexample which shows that this algorithm may not give an optimal solution.

(b) Let a[i] denote the weight of a maximum-weight independent set when only considering the first i vertices of the path. Give the values a[1], a[2], a[3], and a[4] for the example given above.

(c) Define a recursive definition of a[i]. Don’t forget the base case.

(d) Give a bottom-up dynamic programming algorithm based off your recursive definition. What is the running time of your algorithm?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/I Function prototype placed before the function is used double getArea (double); // without the parameter nane int max(int,/* Testing max function (TestMaxFunction.cpp) #include <iostream» using namespace std; 3 4 5 int maximum(int, int); // FunctiBoolean Functions A boolean function returns a bool value (of either true or false) to the caller Suppose that we wish to wri

Add a comment
Know the answer?
Add Answer to:
Give pseudocode that performs the traceback to construct an LCS from a filled dynamic programming table...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program Purpose In this program you will demonstrate your knowledge in programming OOP concepts, such as classes, encapsulation, and procedural programming concepts such as lınked lists, dynamic me...

    Program Purpose In this program you will demonstrate your knowledge in programming OOP concepts, such as classes, encapsulation, and procedural programming concepts such as lınked lists, dynamic memory allocation, pointers, recursion, and debugging Mandatory Instructions Develop a C++ object oriented solution to the Towers of Hanoi puzzle. Your solution will involve designing two classes one to represent individual Disk and another to represent the TowersOfHanoi game. TowersOfHanoi class will implement the game with three linked lists representing disks on each...

  • 2. (25) [Rising trend] Textbook Exercise 17 in Chapter 6. The problem to solve is, in other words...

    2. (25) [Rising trend] Textbook Exercise 17 in Chapter 6. The problem to solve is, in other words, to select from a sequence of n numbers a subset, including the first number, such that the selected numbers make a longest monotonously increasing sequence. In the exercise b, (i) write an optimal substructure (with an explanation),ii) write the iterative dynamic programming algorithm (pseudocode), and (iii) show the running-time analysis. Hints: the algorithm in the exercise a is a greedy algorithm; the...

  • can anyone provide answers with explaination ? thanks a lot I. In the example of recycling...

    can anyone provide answers with explaination ? thanks a lot I. In the example of recycling the elements of a list in O1) time, which situation holds? A. Both lists are circular B. Both ists are not circular C. The list to be recycled is circular, the garbage list is not D. The garbage list is circular, the list to be recycled is not 2. What is the worst-case time to perform MINIMUML) for a sorted, doubly-linked list with nodes?...

  • Problem definition: Give the program that implement Prim’s algorithm. Input: First line is N, denotes the...

    Problem definition: Give the program that implement Prim’s algorithm. Input: First line is N, denotes the amount of test case, then there are Ns graph data with an option number (determine whether output the selected edges or not). Each graph is undirected and connected, it is composed of V (the number of vertices, <= 1000), E (the number of edges, <=10000), then followed by Es edges which are denoted by pair of vertex and weight (e.g., 2 4 10 means...

  • Part B (BI). Implement a Red-Black tree with only operation Insert(). Your program should read from...

    Part B (BI). Implement a Red-Black tree with only operation Insert(). Your program should read from a file that contain positive integers and should insert those numbers into the RB tree in that order. Note that the input file will only contain distinct integers. Print your tree by level using positive values for Black color and negative values for Red color Do not print out null nodes. Format for a node: <Node_value>, <Parent_value>). For example, the following tree is represented...

  • Programming Language: JAVA Construct a program that uses an agent to solve a Sudoku puzzle as...

    Programming Language: JAVA Construct a program that uses an agent to solve a Sudoku puzzle as a Constraint Satisfaction Problem, with the following guidelines: 1. Since 3 x 3 puzzles are too trivial for a computer, your program should use 4 x 4 puzzles (also known as Super Sudoku puzzles; see Figure 2 for an example). 2. The program should read a Sudoku puzzle from a text file. The user should be able to browse the file system to select...

  • How can I get started in this program for this DelivC?

    SpecificationStart with your Java program "prog340" which implements Deliverables A and B.This assignment is based on the definition of the Traveling Salesperson Problem (the TSP): Given a set of cities, you want to find the shortest route that visits every city and ends up back at the original starting city. For the purposes of this problem, every city will be directly reachable from every other city (think flying from city to city).Your goal is to use a non-genetic local search...

  • I am stuck with this coding problem from edx coding python 4.4.6: #This is a long...

    I am stuck with this coding problem from edx coding python 4.4.6: #This is a long one -- our answer is 20 lines of code, but #yours will probably be longer. That's because it's one of the #more authentic problems we've done so far. This is a real #problem you'll start to face if you want to start creating #useful programs. # #One of the reasons that filetypes work is that everyone #agrees how they are structured. A ".png" file,...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT