Analysis of algorithm | Computer Science homework help

CS5200 Homework – 2
(Deadline: 10-06-2023 11:59pm)

Instructor: Huiyuan Yang

q Theory questions [60%] :

Q1.[10%] Given an unordered list, show the corresponding heap after each step.

§ Build a Max-Heap by calling Max-Heapify() algorithm [3%]
§ Delete the maximum item; [2%]
§ Insert an item with value of 80; [2%]
§ Show the heap after 30 is sorted when performing heapsort.[3%]

Q2. [10%] Given a Binary Search Tree,

§ Print out all the keys in the BST in Pre-order, In-order and Post-order; [6%]
§ Show the BST after performing insert(13), insert(40) and delete(35) respectively; [4%]

Q3: [10%] Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is:

§ Print the corresponding m-table, s-table and an optimal parenthesization solution..

Q4.[15%] Given strings X=CACMYCCA, and Y=YMCMAMYCCMA

§ Find the longest common subsequence for the strings X and Y. Show the table with the lengths
and arrows (“← “, ” ↑ “, ” ↖ “) [10%]

§ Find the longest contiguous subsequence. Show the table with the lengths. [5%]

Q5. [15%] Constructing the optimal binary tree, given

§ Show the dynamic programming tables, optimal binary tree and expected search cost.

q Programming [35%]
Dynamic programming solution for LCS.
§ [35%] Given two strings, find the length of the longest subsequence present in both of them. For

example:
o LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of length 3.
o LCS for input Sequences “AGGTAB” and “GXTXAYB” is “GTAB” of length 4.

§ [Extra 10%] Given two strings, find the length of the longest contiguous subsequence present in

both of them. For example:
o LCS for input Sequences “ABCDEEF” and “AEDEEF” is “DEEF” of length 4.

q Bonus: [Extra 10%]

Design a dynamic programming algorithm to solve the sum of subsets problem:

Problem statement: There are n positive integers 𝐴 = [𝑎!, 𝑎”, … , 𝑎#] and a positive integer sum 𝑆. Is
there a subset of A such that the sum of the integers in the subset is 𝑆. If there is such a subset, the
output of the program is true, otherwise it is false.

Example:

§ 𝐴 = [3, 5, 11] 𝑎𝑛𝑑 𝑆 = 16. In this case the output is true since 5 + 11 = 16
§ 𝐴 = [3, 5, 11] 𝑎𝑛𝑑 𝑆 = 18. In this case the output is false since 𝑡ℎ𝑒𝑟𝑒 𝑖𝑠 𝑛𝑜 𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛.
§ 𝐴 = [3, 5, 11,15, 22, ] 𝑎𝑛𝑑 𝑆 = 30. In this case the output is true since 3 + 5 + 22 = 30

This problem can be solved with dynamic programming.

1) Define the optimal substructure, and write the recurrence for the solution. [5%]
2) Write pseudo code, and apply dynamic programming to the following problem: 𝐴 =

[1, 2, 4] 𝑎𝑛𝑑 𝑆 = 6. Show your dynamic programming table. [5%]

q Submission requirements: [5%]

Put the theory part and code into a folder with the name: [YourStudentID-YourName-HW*].zip

§ Following all the submission requirements [5%]
§ Theory part:

o You solution should be clear, concise but also contain enough details.
o Only PDF format is allowed.
o Please make sure the scanned PDF file is high-resolution and easily readable if you wrote

your solution on paper.
§ Programming part:

o A sanity check to test the correctness of your algorithm.
o Your program will read an input file and write an output file.
o Your program will be called like this: prompt>./hw* ./input.txt. ./output.txt
o Your code should be complied by calling the makefile.

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more