Figuring out big O'notation of a naive depth-first-search scheduling algorithm

107 Views Asked by At

(I'm not sure if this question belongs here, but stack overflow doesn't work with LaTeX so here it is)

An inefficient solution to a scheduling problem similar to the 2018 Google Hashcode problem (unless you already know of this problem I wouldn't recommend reading it for this, it will likely overcomplicated this).

Given $n$ tasks and $m$ agents and that 1 agent can do 1 task at a time, you want to assign agents to tasks such that all tasks are completed in the minimum amount of time.

An extremely expensive algorithm is an application of depth-first-search, constructing a tree of every possible assignment and from that finding the shortest path (minimum time required).

Considering a problem with 2 agents and 3 tasks, for each node in each layer you have so many outgoing edges (considering at layer $i$ there are $n+1-i$ tasks remaining):

  1. $mn = 2 \cdot 3 = 6$
  2. $m(n-1)=2 \cdot 2 = 4$
  3. $m(n-2)=2 \cdot 1 = 2$

As such the number of outgoing edges you have in each layer are:

  1. $mn=\frac{n!}{(n-1)!}m^1=2 \cdot 3 = 6$
  2. $mn\cdot m(n-1)=\frac{n!}{(n-2)!}m^2=(2 \cdot 3)(2 \cdot 2) = 24$
  3. $mn\cdot m(n-1)\cdot m(n-2)=\frac{n!}{(n-3)!}m^3=(2 \cdot 3)(2 \cdot 2)(2 \cdot 1) = 48$

Therefore one could give the total number of edges in the network as $t$ where:

$t=\sum\limits_{i=1}^{n} \frac{n!}{(n-i)!}m^i$

At this point I am stuck and do not know how I could simplify it further.

1

There are 1 best solutions below

0
On BEST ANSWER

$$t_{m,n}=\sum\limits_{i=1}^{n} \frac{n!}{(n-i)!}m^i=e^{\frac{1}{m}}\, m^n\, \Gamma \left(n+1,\frac{1}{m}\right)-1$$ where appears the incompleta gamma function.

$$\left( \begin{array}{ccc} m & n & t_{m,n} \\ 1 & 1 & 1 \\ 1 & 2 & 4 \\ 1 & 3 & 15 \\ 1 & 4 & 64 \\ 1 & 5 & 325\\ 2 & 1 & 2 \\ 2 & 2 & 12 \\ 2 & 3 & 78 \\ 2 & 4 & 632 \\ 2 & 5 & 6330\\ 3 & 1 & 3 \\ 3 & 2 & 24 \\ 3 & 3 & 225 \\ 3 & 4 & 2712 \\ 3 & 5 & 40695 \\ 4 & 1 & 4 \\ 4 & 2 & 40 \\ 4 & 3 & 492 \\ 4 & 4 & 7888 \\ 4 & 5 & 157780 \\ 5 & 1 & 5 \\ 5 & 2 & 60 \\ 5 & 3 & 915 \\ 5 & 4 & 18320 \\ 5 & 5 & 458025 \end{array} \right)$$