CS 4520 Georgia State University Algorithm Design and Analysis Project Need help with the assignment. should not be copied from chegg. should be unique LAST NAME , FIRST NAME
CS 4520/6520 Summer 2020
Homework #2, out of 60 pts
Problem 1 [10pts]. Heapsort
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 youre 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
Purchase answer to see full
attachment
Consider the following information, and answer the question below. China and England are international trade…
The CPA is involved in many aspects of accounting and business. Let's discuss some other…
For your initial post, share your earliest memory of a laser. Compare and contrast your…
2. The Ajax Co. just decided to save $1,500 a month for the next five…
How to make an insertion sort to sort an array of c strings using the…
Assume the following Keynesian income-expenditure two-sector model: AD = Cp + Ip Cp = Co…