Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6612843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:08:47+00:00 2026-05-25T20:08:47+00:00

Problem Description: there is n tasks , and in these tasks, one might be

  • 0

Problem Description:

there is n tasks, and in these tasks, one might be dependent on the others, which means if A is dependent on B, then B must be finished before A gets finished.

1.find a way to finish these tasks as quickly as possible?

2.if take parallelism into account, how to design the program to finish these tasks?

Question:

Apparently, the answer to the first question is, topological-sort these tasks, then finish them in that order.

But how to do the job if parallelism taken into consideration?

My answer was,first topological-sort these tasks, then pick those tasks which are independent and finish them first, then pick and finish those independent ones in the rest…

Am I right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:08:48+00:00Added an answer on May 25, 2026 at 8:08 pm

    Topological sort algorithms may give you various different result orders, so you cannot just take the first few elements and assume them to be the independent ones.

    Instead of topological sorting I’d suggest to sort your tasks by the number of incoming dependency edges. So, for example if your graph has A –> B, A –> C, B –> C, D–>C you would sort it as A[0], D[0], B[1], C[3] where [i] is the number of incoming edges.

    With topological sorting, you could also have gotting A,B,D,C. In that case, it wouldn’t be easy to find out that you can execute A and D in parallel.

    Note that after a task was completely processed you then have to update the remaining tasks, in particular, the ones that were dependent on the finished task. However, if the number of dependencies going into a task is limited to a relatively small number (say a few hundreds), you can easily rely on something like radix/bucket-sort and keep the sort structure updated in constant time.

    With this approach, you can also easily start new tasks, once a single parallel task has finished. Simply update the dependency counts, and start all tasks that now have 0 incoming dependencies.

    Note that this approach assumes you have enough processing power to process all tasks that have no dependencies at the same time. If you have limited resources and care for an optimal solution in terms of processing time, then you’d have to invest more effort, as the problem becomes NP-hard (as arne already mentioned).

    So to answer your original question: Yes, you are basically right, however, you lacked to explain how to determine those independent tasks efficiently (see my example above).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem description There are different categories which contain an arbitrary amount of elements .
Ok here is my problem : Before i start the description, let me to
Problem description: I have a POJO object, which is mapped from database. Which having
I am having exactly this problem in my Siverlight4 application: Description There is an
I know that there must be a really simple solution to the below problem
Problem description: Read an xml file, traverse to a particular node (element), if it
Expanding this question on how I learnt to pass from problem description to code
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
Uhm I'm not sure if anyone has encountered this problem a brief description is
I'm having a problem with this: -(id)initWithName:(NSString *)n description:(NSString *)d url:(NSString *)u { I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.