Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Dynamic programming

Perform heapsort in the given max-heap, sort from largest to smallest value (descending order).
You should copy-paste template as many times as needed (and disregard extra nodes if they
appear in the template or in your later heaps’ drawings) and show each step/change.
Max-heap.
Take out 11 as the first element in sorted array of numbers. Then place … as a root node. Then…
This is the template to use.
Problem 2 [10pts]. BST, insertion
Insert key ‘7’ as a root for the following binary search tree.
Use left and right rotations as needed. (First, you need to add key ‘7’ to the tree in its correct
place, and then start rotating, as was shown in lecture). Show all steps.
Problem 3 [20pts].
Imagine you’re a tourist on Manhattan, and this grid models it. You start at upper left corner
(with coordinates 0,0) and should end up at the bottom right corner (with coordinates 4,4).
Weights on edges indicate how many attractions you will see if you walk on that street/avenue.
Your goal is to see as many attractions as possible.
Fill in the matrices A (values, max numbers of attractions one can see up to that “road
intersection”) and B (arrows, so one can reconstruct the path).
a) Using greedy approach
A:

B: (copy-paste appropriate arrows) → ↓ → ←
b) Using Dynamic programming
A:
B:
Problem 4 [10pts]. Knapsack problem
You are given 5 items with weights 4,1,3,3,2 and respective values of 10, 7, 8, 9, 11.
Find the most valuable combinations of items that would fit in a knapsack of weight 8, by
constructing a DP table and calculating all values in the table. For the last two rows, show
explicitly how you use the formula from the slides.
(You are asked to do this to show understanding. Usually by performing such task, you finally
“get” it and see why formula works and is correct and what it actually states )
Answer:
Problem 5 [10pts]. LCS
By constructing a DP table, find the longest common subsequence for the two given sequences:
S1: ACCTGATCGA
S2: CTTACAGTAC
Your table has to be constructed in a fashion as was done in lecture, and should contain numbers
which represent how many common characters are found by now, and arrows so the LCS is reconstructible.
Answer: LCS is

Sample Solution

The post Dynamic programming appeared first on coursesolver.

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"