MIT6_851S10_assn01_sol - 6.851 Advanced Data Structures...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 6.851 Advanced Data Structures (Spring’10) Prof. Erik Demaine Dr. Andr´ Schulz e Problem 1 TA: Aleksandar Zlateski Sample Solutions Transposing a matrix. Consider a point set {(xi , i)} of k 2 points on a k 2 × k 2 lattice representing �� � � the access � equence. For each point (xi , i) we introduce three new points at (xi − 1, i), k xi , i s� k �� and k xi , i . k The newly formed set is Aborally Satisfied, hence it represents a valid BST execution. The set contains O(k 2 ), giving amortized cost of O(1) per access. Logarithmic redux. Consider the access sequence, the point set X = {(xi , i)} of m points on a n × m lattice. Let x be the median of all x ∈ X . Inserting m points (x, i) will ensure that each ˆ ˆ rectangle connecting a point left of or at x and a point right of or at x contains a point. ˆ ˆ Now consider the two subsets of X , Xx≤x and Xx≥x , each with at most m points, and at most ˆ ˆ n 2 distinct x values. We recursively apply the same technique, to obtained point set that is Aborally Satisfied. We get the number of newly inserted points by solving the recursion N (m, n ) = 2N (m, n , n) + m. 2 2 The total number of accesses is then O(N (m, n) + m) = O(m log n + m) = O(m log n). 1 MIT OpenCourseWare 6.851 Advanced Data Structures Spring 2010 For information about citing these materials or our Terms of Use, visit: ...
View Full Document

This note was uploaded on 03/31/2011 for the course EECS 6.851 taught by Professor Erikdemaine during the Spring '10 term at MIT.

Page1 / 2

MIT6_851S10_assn01_sol - 6.851 Advanced Data Structures...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online