Design and Analysis of Algorithms
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP 3711 – Design and Analysis of Algorithms
Your solution should contain
(i) your name, (ii) your student ID #, and (iii) your email address
at the top of its first page.
Some Notes:
• Please write clearly and briefly. In particular, your solutions should be written or printed on clean
white paper with no watermarks, i.e., student society paper is not allowed.
• Please also follow the guidelines on doing your own work and avoiding plagiarism as described on
the class home page. You must acknowledge individuals who assisted you, or sources where you found
solutions. Failure to do so will be considered plagiarism.
• The term Documented Pseudocode means that your pseudocode must contain documentation, i.e.,
comments, inside the pseudocode, briefly explaining what each part does.
• Many questions ask you to explain things, e.g., what an algorithm is doing, why it is correct, etc. To
receive full points, the explanation must also be understandable as well as correct.
• Please make a copy of your assignment before submitting it. If we can’t find your submission, we will
ask you to resubmit the copy.
• Submit a SOFTCOPY of your assignment to Canvas by the deadline. If your submission is a scan of
a handwritten solution, make sure that it is of high enough resolution to be easily read. At least 300dpi
and possiblydenser.
Question 1 (20%): Maximum sum in binary tree
Given a binary tree where each node has a positive number, describe a dynamic programming algorithm
to select the subset of nodes with the maximum sum provided that adjacent nodes cannot be picked. In
the following example, the shaded nodes form the optimal solution. For full credits, your algorithm
should run in O(n) time, where n is the number of nodes. The algorithm just needs to output the sum,
not the actual nodes picked.