1 / 19

CSE 202 Divide-and-conquer algorithms

CSE 202 Divide-and-conquer algorithms. Fan Chung Graham UC San Diego. Trees with at most 4 edges. A useful fact about trees. Any tree on n vertices contains a vertex v whose removal separates the remaining graph into two parts, one of which is of sizes

sondra
Download Presentation

CSE 202 Divide-and-conquer algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 202 Divide-and-conquer algorithms Fan Chung Graham UC San Diego

  2. Trees with at most 4 edges

  3. A useful fact about trees Any tree on n vertices contains a vertex v whose removal separates the remaining graph into two parts, one of which is of sizes at most n/2 and the other is at most 2n/3.

  4. Ternary trees

  5. A useful fact about trees Any tree on n vertices contains a vertex v whose removal separates the remaining graph into two parts, one of which is of sizes at most n/2 and the other is at most 2n/3. Try to write a proof for this!

  6. A planar graph is a graph that can be drawn in the plane without crossings.

  7. A planar graph is a graph that can be drawn in the plane without any crossing. Are these planar graphs?

  8. A planar graph is a graph that can be drawn in the plane without any crossing. Are these planar graphs?

  9. A useful fact about planar graphs Any planar graph on n vertices contains vertices whose removal separates the remaining graph into two parts, one of which is of sizes at most n/2 and the other is at most 2n/3. Tarjan and Lipton, 1977

  10. Merge-and-Count(A,B) algorithm Input: sorted Output: a sorted list L, count of # inversions in Initially, a pointer at first element of A, a pointer at first element of B, size of A, also, set count =0,and While if increase count by size of A, move the pointer of B by 1, else, move the pointer of A by 1, decrease size by 1, endif endwhile to L append smaller of

  11. Implementing sort-and-count algorithm Running time O(n log n)

More Related