Question
{50 points} After attending a lecture on topological sorting, Samantha thinks of a new way of performing topological sort. Her algorithm is as follows. input(Directed
{50 points} After attending a lecture on topological sorting, Samantha thinks of a new\ way of performing topological sort. Her algorithm is as follows.\ input(Directed graph G)\ l []\ while G has more than zero nodes do\ Find a node v with no outgoing edges in G\ Add v to l\ Delete v from G\ return l in reverse order\ (a) Is Sams algorithm correct? If so, demonstrate why it is correct? If not, find a counter\ example where Sams algorithm returns a list that is not a topological ordering of G.\ (b) Is this algorithm more efficient than the one we discussed in the class? Use \\\\Theta , ,\ and/or O notation in your argument.\ (c) What happens to Sams algorithm if the input is not a DAG?
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