Skip to main content
1 of 2
Jesse Q
  • 251
  • 2
  • 6

Time Complexity of Parallel.ForEach

Pseudo code and comments to explain:

// first select companies to process from db

foreach (company) {
    // select the employees
    foreach (employee of company) {
        // select items they can access
        foreach (item) {
           // do some calculation and save

I believe this will be O(n^3) time complexity, please correct me if I am wrong - Big O has always given me a headache. My question is if you introduce Parallel processing at the first level, what does it become? What if we introduce a second parallel.foreach() for the second iteration as well?

Jesse Q
  • 251
  • 2
  • 6