
Minimum Spanning Tree Manhattan Distance Problem Solution
"Explore the solution to finding a minimum spanning tree for a set of points based on Manhattan distance in this informative visual guide. Learn about pruning the graph and optimizing algorithms for efficient computation."
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
PS Bonus Debrief By Le Beier
Problem Given N points(x, y), the weight between each pair of points are given by the manhattan distance. Find a minimum spanning tree(MST) manhattan distance = |X1- X2| + |Y1-Y2|
Constraints 1 <= N <= 100, 000 0 <= (x, y) <= 1000 Remove Duplicates Points are non-distinct edge weight = manhattan distance
For i = 0 n: For k = 0 n: Add edge(point_i, point_k, dist) into Edge List Result = MST(Edge List)
O(N^2) + O(E log N) = O(N^2 log N) * E = N^2 Since N = 100000 100000^2 log 100000 = 166096404744 166096404744
TLE TLE AC Solution
Prune the graph How?
O(XY)+O(XY log XY) = O(XY log XY) Note: 0<= X, Y < 1000 O(1000000 log 1000000) = 19931568
Delaunay Triangulation Using line sweep algorithm which runs in O(n log n)
https://www.topcoder.com/communi ty/data-science/data-science- tutorials/line-sweep-algorithms/