Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2 Minimum Spanning Tree Check Given two undirected weighted graphs G1 and G2 , write a function named CheckMST which checks if G2 is a

Q2

Minimum Spanning Tree Check

Given two undirected weighted graphs G1 and G2, write a function named CheckMST which checks if G2 is a valid MST for G1. The function returns true when valid and false otherwise.

Input

Your function takes as input three integers: V, E1, and E2 where V is the number of Vertices, E1 is the number of edges for the first graph G1, and E2 is the number of edges for the second graph G2 and:

3 integer arrays for edges information for graph 1: From1[], To1[], Weight1[]

3 integer arrays for edges information for graph 2: From2[] ,To2[], Weight2[]

Output

Yes or No

Example 1:

V=4 E1=5 E2=4

Graph 1 info

From To Weight 0 1 4 0 2 5 0 3 2 1 2 7 2 3 8

Graph 2 info

From To Weight 0 1 4 0 2 5 0 3 2 1 2 7

Answer:

NO

Example 2:

V=4 E1=5 E2=4

Graph 1 info

From To Weight 0 1 4 0 2 5 0 3 2 1 2 7 2 3 8

Graph 2 info

From To Weight 0 1 4 0 2 5 0 3 2

Answer:

YES

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

1. Who is responsible for resolving this dilemma?

Answered: 1 week ago

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago