Question 1 (16 + 16 = 32 Points): Let there is an undirected graph with 10...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 1 (16 + 16 = 32 Points): Let there is an undirected graph with 10 nodes with the following edges (x-y means x and y are connected): 1-4, 1-2, 2-3, 2-8, 2-5, 2-7, 3-9, 3-10, 4-3, 5-6, 5-7, 5-8, 8-7. Now, I. Apply DFS considering 1 as the source node. If there are multiple options at any step, pick the node with smaller index. Draw the DFS tree. Also, mention all the back-edges. II. Repeat part II considering 6 as the source node. Question 2 (42 Points): Given a graph that is undirected, write a code that checks if it contains any cycle or not. Please use BFS or DFS to solve this problem. Do not use any built-in methods and your output must matches the sample input/output. Check the sample input below: Sample Input 1: Number of Nodes and Edges: 12 12 Edge Information: (0, 1), (0, 6), (0, 7), (1, 2), (1, 5), (2, 3), (2, 4), (7, 8), (7, 11), (8, 9), (8, 10), (10, 11) Output: This graph contains a cycle, and (7, 8), (7, 11), (8, 10), (10, 11) forms the cycle You must test the following three test cases with your code and attach the output. Sample Input 1: Number of Nodes and Edges: 12 12 Edge Information: (0, 1), (0, 6), (0, 7), (1, 2), (1, 5), (2, 3), (2, 4), (7, 8), (3, 4), (7, 11), (8, 9), (8, 10) Output: ??? Sample Input 2: Number of Nodes and Edges: 12 12 Edge Information: (0, 1), (0, 6), (0, 7), (1, 2), (1, 5), (4, 5), (2, 3), (2, 4), (7, 8), (7, 11), (8, 9), (8, 10) Output: ??? Question 1 (16 + 16 = 32 Points): Let there is an undirected graph with 10 nodes with the following edges (x-y means x and y are connected): 1-4, 1-2, 2-3, 2-8, 2-5, 2-7, 3-9, 3-10, 4-3, 5-6, 5-7, 5-8, 8-7. Now, I. Apply DFS considering 1 as the source node. If there are multiple options at any step, pick the node with smaller index. Draw the DFS tree. Also, mention all the back-edges. II. Repeat part II considering 6 as the source node. Question 2 (42 Points): Given a graph that is undirected, write a code that checks if it contains any cycle or not. Please use BFS or DFS to solve this problem. Do not use any built-in methods and your output must matches the sample input/output. Check the sample input below: Sample Input 1: Number of Nodes and Edges: 12 12 Edge Information: (0, 1), (0, 6), (0, 7), (1, 2), (1, 5), (2, 3), (2, 4), (7, 8), (7, 11), (8, 9), (8, 10), (10, 11) Output: This graph contains a cycle, and (7, 8), (7, 11), (8, 10), (10, 11) forms the cycle You must test the following three test cases with your code and attach the output. Sample Input 1: Number of Nodes and Edges: 12 12 Edge Information: (0, 1), (0, 6), (0, 7), (1, 2), (1, 5), (2, 3), (2, 4), (7, 8), (3, 4), (7, 11), (8, 9), (8, 10) Output: ??? Sample Input 2: Number of Nodes and Edges: 12 12 Edge Information: (0, 1), (0, 6), (0, 7), (1, 2), (1, 5), (4, 5), (2, 3), (2, 4), (7, 8), (7, 11), (8, 9), (8, 10) Output: ???
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Benchmarks should meet the following criteria EXCEPT Question 50 options: they should be constructed in an objective manner. they should be based only on information available to the manager. they...
-
Let there is an undirected graph with 10 nodes with the following edges (x-y means x and y are connected): 1-2, 1-5, 1-7, 2-3, 2-5, 3-4, 3-5, 4-5, 4-10, 5-6, 6-7, 6-8, 6-9, 6-10, 7-8, 8-9, 9-10. Now,...
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Ski Aus is a company that makes fashionable, high performance and expensive ski clothing (ski wear). Ski Aus has traditionally segmented the market by clothing type (e.g., ski pants, ski jackets,...
-
In April 2009, the Gallup organization surveyed 676 adults aged 18 and older and found that 352 believed they would not have enough money to live comfortably in retirement. Does the sample evidence...
-
In Problems, find the steady-state vector associated with the given transition matrix from Problems 912. 0.5 0.3 0.2 C = 0.3 0.5 0.2 0.1 0.1 0.8
-
Which of the following statements is true? a. Financial statements report the value of employee knowledge and skills. b. Turnover and absenteeism are costly. c. Outsourcing of HRM and payroll...
-
If a firm pays its bills with a 30-day delay, what fraction of its purchases will be paid in the current quarter? In the following quarter? What if the delay is 60 days?
-
B56 Xfx =(B48/((1+B55)^1)+B48/((1+B55)^2)+C48/((1+B55)^3))-B41-840 B C D E F G H A On their latest income statement, Emily's Construction reported sales of $674,000, costs of $391,600, depreciation...
-
Identifying financing, investing, and operating transactions Required For a company like Canadian Tire Corporation, provide two examples of transactions that you would classify as financing,...
-
Calculate the carrying value of vehicles at the end of the year Balances on 28 February 2021 Balance sheet section Vehicles at cost Equipment at cost Inventory Provision for bad debts Nominal...
-
Shane has organised an appointment to come and speak to you as he needs some support. Shane's wife of 40 years, Kate, has recently been diagnosed with a terminal illness. Shane tells you that this...
-
One of the variable production costs is the cost of steel. The standards for steel purchase prices and usage as setat the beginning of 2016 were: Standard priceof steel $25.00 perpound Standard...
-
What is the average tax rate on a corporation with $ 7 5 , 0 0 0 in income and a tax liability of $ 1 5 , 0 0 0 ?
-
Suppose there are only two types of goods being produced in Peru: Vegetables and Plastic Cups. Suppose the Vegetables are produced with labor and land while the Plastic Cups are produced with labor...
-
Current position: Ambulatory Services Rep II -Bone Marrow Transplant Clinic 1.What have been your top work-related successes during the first half of the fiscal year? 2. What are your key...
-
This activity has the purpose of helping students to perform the forecast models (Objective 6). Student Instructions: Answer the following exercises. This assignment has a value of 30 points. You...
-
Do the three planes x + 2x + x 3 = 4, X X 3 = 1, and x + 3x = 0 have at least one common point of intersection? Explain.
-
Consider a publicly-held company whose products you are familiar with. Some examples might include: Access the companys public website and search for its most recent annual report. (Note: Some...
-
The 2014 financial statements of LVMH Moet Hennessey-Louis Vuitton S.A. are presented in Appendix C of this book. LVMH is a Paris-based holding company and one of the worlds largest and best-known...
-
San Francisco Sea Salt's controller prepared the following statements of cash flow (in thousands of dollars) for the past two years, the current year (2020), and the upcoming year (2021): After...
Study smarter with the SolutionInn App