Please Help If it's too long just do either one or two Analysis of Algorithms

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: 899604
Joined: Mon Aug 02, 2021 8:13 am

Please Help If it's too long just do either one or two Analysis of Algorithms

Post by answerhappygod »

Please Help
If it's too long just do either one or two
Analysis of Algorithms
Please Help If It S Too Long Just Do Either One Or Two Analysis Of Algorithms 1
Please Help If It S Too Long Just Do Either One Or Two Analysis Of Algorithms 1 (112.6 KiB) Viewed 34 times
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 u; 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 nodet. 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: 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,6 = 2 Output: true Explanation: There is one path from node 0 to node 2. Problem 2. (Category: Simulating and coding: Topological order] 1. Simulating: Consider the directed acyclic graph G below, how many topological orderings does it have? List all the orderings. [5 points) 2. Coding: Course schedule problem (10 points) There are a total of n courses you have to take, labeled from 0 to n - 1. You are given an array prerequisites where each element prerequisites = [C1,C) indicates that you must take course c; first if you want to take course . For example, the pair (0, 1), indicates that to take course you have to first take course 1. Your task is write a function that takes the number of courses n, and prerequisites array as parameter, return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply