TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Farhan Shariff
NA
933
241.7k
finding the order of execution of the Jobs
May 8 2016 11:55 AM
Suppose a job is represented by a single character. Maybe a job “a” must be completed before job “b”, then job “b” depends on “a”. Any job may depend on any number of other jobs. After registering jobs with their dependencies the class should compute the order of jobs for execution.
The interface is defined as:
interface OrderedJobs { void register(char job);
void register(char job, char dependentJob);
String[] sort();
}
For example, registering the following jobs:
register('c'); register('b', 'a'); register('c', 'b');
sort() should return this result: "abc".
The same job appeared in multiple registrations just occurs once in the result of sort(). Jobs with no dependency can occur in any order as long as they are executed before jobs which depend on them. Circular dependencies between jobs should be reported through an exception (at least in the method sort()).
Reply
Answers (
4
)
Constructor class B and derived class D
real time chart and databse