please help thanks Problem 1. [Category: Coding: Find if path exists in graph] Given an undirectional graph with n nodes

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

please help thanks Problem 1. [Category: Coding: Find if path exists in graph] Given an undirectional graph with n nodes

Post by answerhappygod »

please help thanks
Problem 1. [Category: Coding: Find if path exists in graph]
Given an undirectional graph with n nodes, where each node is
labeled from 0 to n−1 (inclusive). The edges in the graph is
represented by array edges where each element edges = [ui, vi]
denotes an undirectional edge between node ui and node vi. Every
node pair is connected by at most one edge, and no vertex has an
edge to itself. Your task: is to determine if there is a valid path
exists from node s to node t. Given edges and the integers
n, s, and t, return true if there is a valid path from s to t,
or false otherwise.
Example:

Please Help Thanks Problem 1 Category Coding Find If Path Exists In Graph Given An Undirectional Graph With N Nodes 1
Please Help Thanks Problem 1 Category Coding Find If Path Exists In Graph Given An Undirectional Graph With N Nodes 1 (12.4 KiB) Viewed 66 times
Input: n = 6, edges = [[0, 1], [0, 2], [3, 5], [5, 4], [4, 3]],
s = 0, t = 5 Output: false Explanation: There is no path from node
0 to node 5.
Input: n = 6, edges = [[0, 1], [0, 2], [3, 5], [5, 4], [4, 3]],
s = 0, t = 2
[10 points]
Output: true Explanation: There is one path from node 0 to node
2.
Problem 2. [Category: Simulating and coding: Topological
order]
Please Help Thanks Problem 1 Category Coding Find If Path Exists In Graph Given An Undirectional Graph With N Nodes 2
Please Help Thanks Problem 1 Category Coding Find If Path Exists In Graph Given An Undirectional Graph With N Nodes 2 (9.6 KiB) Viewed 66 times
2 5

6 с a f d e
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply