Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

11/27/21, 7:12 PM 1. Draw A Dependency Graph Between Any Two Courses... | Chegg.

com

  Home Study tools


 My courses
 My books Career Life 

Find solutions for your homework Search

home / study / engineering / computer science / computer science questions and answers / 1. draw a dependency graph between any two courses fr…

Post a question
Your question has been answered Answers from our experts for your tough
homework questions
Let us know if you got a helpful answer. Rate this answer
Enter question

Question: 1. Draw a dependency graph between any two courses from th…
Continue to post
4 questions remaining

Snap a photo from your


phone to post a question
We'll send you a one-time download
link

888-888-8888 Text me

By providing your phone number, you agree to receive a one-time


automated text message with a link to get the app. Standard
messaging rates may apply.

My Textbook Solutions

Intermediat... Fundament... Operations...

12th Edition 5th Edition 10th Edition

View all solutions

Show transcribed image text

Expert Answer

Anonymous answered this


Was this answer helpful? 0 0
First answer!

First of all, you need to draw a dependency graph. so, if course


v has a prerequisite course u then you will
add a directed edge
From node u to node v.Rate answer here.

for example, CSE201 has a prerequisite course as CSE103. so,


there will be a directed edge from CSE103 to
CSE201. similarly, you
can do it for all the courses and will get a Graph as below.

now, The next Task is to find a linear order of courses such


that prerequisite courses come before any
course in the order. For,
this you can use the algorithm BFS or DFS.

Let's solve the problem using BFS

Idea: First find a node with indegree 0 (i.e. no edge coming


into the node). then set its indegree to -1 and
reduce the indegree
of all of his neighbours by 1. we will repeat this process n(number
of nodes) times.
and the order of picking nodes will be our final
answer.

now, let's try to solve the problem using the above idea.

step 1. let's calculate the indegree of all the nodes.

Course CSE103 CSE105 CSE201 CSE203 CSE205 CSE207 CSE303 CSE309 CSE311 CSE313

Indegree 0 0 1 2 0 1 1 1 1 2

step2. now, pick a node with indegree=0, there are three nodes
with indegree=0. so, we will pick anyone
out of the three. let's
follow the order and pick COL103. now set its indegree to -1.
reduce it's
neighbours(CSE201,CSE203,CSE313) indegree by 1.

Course CSE103 CSE105 CSE201 CSE203 CSE205 CSE207 CSE303 CSE309 CSE311 CSE313

Indegree -1 0 0 1 0 1 1 1 1 1

step3. now, pick again pick a node with indegree=0. so, pick
CSE105. now set its indegree to -1. and
reduce all its
neighbour's(CSE203) indegree by 1.

this way you can proceed and solve. below is the table you will
get after each step.

step Course CSE103 CSE105 CSE201 CSE203 CSE205 CSE207 CSE303 CSE309 CSE311 CSE313

1 Indegree 0 0 1 2 0 1 1 1 1 2

2 Pick -1 0 0 1 0 1 1 1 1 1
CSE103

3 Pick -1 -1 0 0 0 1 1 1 1 1
CSE105

4 Pick -1 -1 -1 0 0 1 1 1 1 1
CSE201

5 Pick -1 -1 -1 -1 0 0 1 1 1 1
CSE203

6 Pick -1 -1 -1 -1 -1 0 0 0 1 1
CSE205

7 Pick -1 -1 -1 -1 -1 -1 0 0 0 1
CSE207

8 Pick -1 -1 -1 -1 -1 -1 -1 0 0 0
CSE303

9 Pick -1 -1 -1 -1 -1 -1 -1 -1 0 0
CSE309

10 Pick -1 -1 -1 -1 -1 -1 -1 -1 -1 0
CSE311

11 Pick -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
CSE313

so, The final order is: CSE103, CSE105, CSE201, CSE203, CSE205,
CSE207, CSE303, CSE309, CSE311,
CSE313,

There are multiple possible answers depending on your


tie-breaking method. here we follow alphabetical
to break ties.

Comment


https://www.chegg.com/homework-help/questions-and-answers/1-draw-dependency-graph-two-courses-table-given--co2-need-find-linear-order-selecting-cour-q88771218?trackid=918f273872c4&strackid=b9e4f260b246 1/2
11/27/21, 7:12 PM 1. Draw A Dependency Graph Between Any Two Courses... | Chegg.com

  Home Study tools


 My courses
 My books Career Life 

COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE

About Chegg Advertising Choices Cheap Textbooks Mobile Apps EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Sell Textbooks Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Solutions Manual Thinkful Help with eTextbooks
Corporate Development Intellectual Property Rights Chegg Study Help Study 101 Help to use EasyBib Plus
Investor Relations Terms of Use College Textbooks Textbook Rental Manage Chegg Study
Jobs Global Privacy Policy eTextbooks Used Textbooks Subscription

Join Our Affiliate Program DO NOT SELL MY INFO Flashcards Digital Access Codes Return Your Books

Media Center Honor Code Learn Chegg Money Textbook Return Policy

Site Map Honor Shield Chegg Math Solver

© 2003-2021 Chegg Inc. All rights reserved.

https://www.chegg.com/homework-help/questions-and-answers/1-draw-dependency-graph-two-courses-table-given--co2-need-find-linear-order-selecting-cour-q88771218?trackid=918f273872c4&strackid=b9e4f260b246 2/2

You might also like