• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
August 21, 2024 |230 Views

SDE Sheet -Minimum Spanning Tree

Description
Discussion

This video is part of the Greedy section under GFG SDE Sheet.

Given an array arr of size containing non-negative integers, the task is to divide it into two sets S1 and S2 such that the absolute difference between their sums is minimum and find the minimum difference


Example 1:

Given a weighted, undirected, and connected graph with V vertices and E edges, your task is to find the sum of the weights of the edges in the Minimum Spanning Tree (MST) of the graph. The graph is represented by an adjacency list, where each element adj[i] is a vector containing vector of integers. Each vector represents an edge, with the first integer denoting the endpoint of the edge and the second integer denoting the weight of the edge.

Example 1:

Input: 3 3 0 1 5 1 2 3 0 2 1
Output: 4
Explanation: The Spanning Tree resulting in a weight of 4 is shown above.

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/minimum-spanning-tree/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/prims-minimum-spanning-tree-mst-greedy-algo-5/