{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

sol1 - Massachusetts Institute of Technology 6.854J/18.415J...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Massachusetts Institute of Technology Handout 4 6.854J/18.415J: Advanced Algorithms Monday, September 21, 2009 David Karger Problem Set 1 Solutions Problem 1. Suppose we have a Fibonacci heap that is a single chain of k - 1 nodes. The following operations make a chain of length k . Let min be the current minimum of the Fibonacci heap: 1. Insert items x 1 < x 2 < x 3 < min in an arbitrary order. 2. Delete the minimum, which is x 1 . 3. Decrease the key of x 3 to be -∞ , i.e. the minimum. 4. Delete the minimum, which is x 3 = -∞ . The second step is the key one: it removes x 1 , joins x 2 and x 3 as a chain, and then joins the original chain with the chain containing x 2 and x 3 (obtaining a tree where x 2 is the root, with x 3 and the original ( k - 1)-nodes chain as children). The third step just removes x 3 from the chain, and the last step completely deletes it. The result is that x 2 is now the root of the original chain, so we have constructed a chain of length k . For the base case, just insert a single node. Thus, we obtain a k-node chain with O ( k ) operations; therefore, we can construct an Ω( n )- node chain with n operations. Note that the decrease-key operation was essential for obtaining Ω( n ) depth: without it, you can only obtain binomial heaps (which have logarithmic depth). Problem 2. For each node, we store a counter of how many of its children were removed (call count i the counter of node i ). To analyze the running time of the operations, we use the following potential function: Φ = # roots + 2 P i count i k 1 . The insert operation has O (1) amortized cost. Note that φ increases by 1 unit as in the case of the original Fibonacci heap. Thus, the cost of insert does not change. The decrease-key operation will have a lower amortized cost. Suppose there are c cascading cuts. Then, the amortized cost of decrease-key is 1 + c + ΔΦ, with ΔΦ = c + 2 c ( k 1)+2 k 1 . Concluding, the cost of decrease-key is 1 + c + c - 2 c + 2 k 1 = 1 + 2 k 1 . Note that in the original Fibonacci heaps, this cost was 1 + 2 = 3. Conversely, the delete-min operation will have a higher amortized cost. The analysis is the same as in the case of the original Fibonacci heaps. Thus, the amortized cost of delete-min is bounded by the maximum degree of a heap in our data structure.
Image of page 1

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

View Full Document Right Arrow Icon
2 Handout 4: Problem Set 1 Solutions
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern