# quiz2sol - Introduction to Algorithms Massachusetts...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6.046J/18.410J Quiz 2 Name 2 Problem 1. Short Answer [20 points] Give brief , but complete, answers to the following questions. (a) In each of the trees below, label the nodes of the tree to make it a red-black tree, or prove that no such labelling exists. Use the following convention: label the black nodes with a ‘B,’ and the red nodes with an ‘R’. B B R B B R R Solution: The second tree cannot be colored, because it has a root-to-leaf path of 5 nodes, and one of 2 nodes. The latter path can have at most 2 black nodes. On the other hand, since the root node must be colored black, and there cannot be two red nodes in a row, the path with 5 nodes must have at least 3 black nodes. This would be a violation of the black-height property.
6.046J/18.410J Quiz 2 Name 3 (b) Name some similarities and differences between the Divide and Conquer and Dy- namic Programming paradigms. For each paradigm, name a problem to which the paradigm is applied. Solution: Similarities: both techniques analyze a problem recursively, and solve sub- problems to arrive at a final answer. Differences: DP takes advantage of overlapping subproblems for efficiency, exploits the “optimal substructure” of problems, and usu- ally fills in a table of values of an objective function in optimization problems.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern