Question
The year is 430BC. Socrastes The Philosopher has a collection of important ethical questions to ponder over. Some of these questions have dependencies, i.e: Is
The year is 430BC. Socrastes The Philosopher has a collection of important ethical questions to ponder over. Some of these questions have dependencies, i.e: Is it eth- ical to consume meat? should be answered before the question What should I eat for lunch? is resolved. Socrastes may only consider one question at a time, but nev- ertheless, Socrastes is a masterful philosopher: whenever Socrastes begins thinking about a question, Socrastes is guaranteed to answer it in a few days. Socrastes will always respect the dependencies between questions in choosing which questions to think about. However, whenever Socrastes has a choice between two questions 2 to ponder, Socrastes will always choose the less important question to think about. 3 Suppose that Socrastes ranks the importance of questions on an integer scale from 1 to 10. If the number of questions is n and the number of dependencies is m, describe an algorithm which returns a possible order that Socrastes might think about the questions in O(n + m) time. Use topological Sort as a framework. Make sure the solution is completed in O(m + n) time.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started