Homework Assignment 8
Assignment
-
(50 points) Explain how to use an AVL tree or a red-black tree to sort
n
comparable elements inO(n log n)
time in the worst case.- Provide and explain pseudocode
- Statement and proof of time complexity. Be clear of the assumptions on the ADT implementations.
- Statement and proof of memory complexity. Be clear of the assumptions on the ADT implementations.
-
(50 points) Suppose we are given two
n
-element sorted sequencesA
andB
each with distinct elements, but potentially some elements that are in both sequences. Describe anO(n)
-time method for computing a sequence representing the unionA ∪ B
(with no duplicates) as a sorted sequence.- Provide and explain pseudocode
- Statement and proof of time complexity. Be clear of the assumptions on the ADT implementations.
- Statement and proof of memory complexity. Be clear of the assumptions on the ADT implementations.
-
Bonus.
(10 points) Describe and analyze an efficient method for removing all
duplicates from a collection
A
ofn
elements.- Provide and explain pseudocode
- Statement and proof of time complexity. Be clear of the assumptions on the ADT implementations.
- Statement and proof of memory complexity. Be clear of the assumptions on the ADT implementations.
General Instructions, Turning in assignments, and Grading
General Instructions
- All homework assignments must be typeset using LaTex. Using another
program (e.g., Microsoft Word) or handwriting assignments will result in
grade of 0. Here is an example homework
problem (click here for pdf) worked out to see the expected format and
the tex file (click here to see it) that
generated it to help you start.
- If you are unfamiliar with LaTex, here is a short tutorial (click here for pdf) and the tex file (click here to see it) that generated it. This tutorial shows how to write common mathematics, how to write pseudocode, how to cite sources, how to include images, and how to include tables.
- Complete every part of every problem!
- On writing an algorithm, use pseudocode and good mathematical style to describe algorithms and data structures. Do not specify Java code unless otherwise stated.
- On time complexity, your goal should be to determine and prove the tightest bound for your algorithm. Be sure to state any assumptions about implementations needed.
- On memory complexity, your goal is to analyze the extra memory consumed by your algorithm, i.e., do not count the memory used by the input to your algorithm.
- Follow turn-in instructions precisely.
- Failure to complete any of these steps will result in a significant loss of points.
Turn in Instructions
Each assignment will be turned in in class (hard copy). Assignments are due BEFORE, let me repeat, before class starts. This does not mean one minute after class starts. Details:
- The first page of your hard copy must be a signed coverpage (click here for pdf).
- Next put the problems in order as described in the description. This may seem silly, but you would be surprised sometimes.
- If you do not know how to print, consult University of Richmond webpages to learn how to use campus printers. If possible, please print 2-sided. Printer issues are not an excuse to turn an assignment in late.
- Staple all pages together.
- I reserve the right to assign a 0 to any assignment failing to comply with these instructions. Even for something as small as a missing staple.
Grading
- Each assignment is graded out of 100 points (not including bonus).
- Expectation and point distribution - this is a general guideline that may
change depending on the specific problem, e.g., proof-only problems may
differ.
- Algorithm description and pseudocode - ~50%
- Provide a written explanation of your algorithmic solution. Provide intuition as to why it computes the correct answer.
- Provide pseudocode of your solution. Be sure to clearly state input and output (if applicable, and a return statement must also be present), and be sure to use ADTs as specified in slides and textbook.
- Statement and proof of time complexity - ~25%
- Provide a theorem/lemma stating assumptions and results.
- Provide a clear proof sketch justifying theorem.
- Statement and proof of memory complexity - ~25%
- Provide a theorem/lemma stating assumptions and results.
- Provide a clear proof sketch justifying theorem.
- Algorithm description and pseudocode - ~50%
- Criteria (includes but is not limited to)
- Efficiency solutions - inefficient algorithms will yield partial credit to the problem.
- Clear and concise technical writing and presentation is the heart of the grade. It is not merely that you solve the problem, it is a function of how well you write your pseudocode and theorems, and how they are explained and proved. Short statements of fact and clear equations are valued over unclear, complex, and lengthy expositions.
- Proper use of LaTeX is also expected. Points will be deducted for not using mathematics mode or LaTeX tables for example.
- If there are any discrepancies in grades, please see the instructor during his office hours or by appointment (do not discuss with the lab assistants or graders).