PLEASE DO ASAP ANALYSIS OF ALGORITHM
Posted: Sat May 14, 2022 3:12 pm
PLEASE DO ASAP
ANALYSIS OF ALGORITHM
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. (10 points) Example: 3 0 2 5 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 1 Output: true Explanation: There is one path from node 0 to node 2.
ANALYSIS OF ALGORITHM
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. (10 points) Example: 3 0 2 5 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 1 Output: true Explanation: There is one path from node 0 to node 2.