Interview Question
Country: India
Interview Type: In-Person
The graph formed would be node A points to node G. B, E are independent nodes.
May be the confusion was with topological sort. Well, the language may or may not have precedence order amongst all of the literals, but you can achieve partial precedence ordering using topo sort.
If you go with Cormen topo sort algo, he returns a single list and would get what you mentioned A > G > B > E.
I didn't mean that.
I somehow couldn't express the second part more clearly.
So you have a DAG and the interviewer needs ordering, see what you can do...
- kartikaditya June 18, 2012