1 rizwank 1.1 Algorigmic Effeciency:
2
3 Step 1 : reading file, entering into backpack, processing
4 (n dependent - linear)
5 (the pqueue insert takes nlogn time actually, but as the
6 comparator is null, logn approaches 1.)
7
8 Worst case:
9 In the _worst_ case scenario, there is no sum of the items that will yield
10 the requested weight. In addition, in the worst case, no trees will be removed
11 due to overflow.
12 Therefore, two of the three major advantages to the branch-and-bound algo
13 (as implemented here), the early removal and the 'pruner' are both useless
14 in the WORST case. (while it has no effect, the internal pqueue that keeps
15 the most likely prospects at the top of the queue still functions).
16 The worst case is 2^n complexity, same as that of an exhaustive search.
17
18 Outside the worst case, we have to note that the result time isn't dependent
19 on the input set size alone. In addition, the expected number of elements
20 that would be needed to fill the crate is an important factor that we will call
21 k. In actuality, it is a combination of k and n that lead to our complexity.
22 rizwank 1.1 K is not precisely determined but can be found nominally by
23 k= (max pallet size)/(avg input mass)
24
25 This indirectly points to the condition in the worst case scenario ---
26 if k > n, there can be no solution. (this is trapped directly)
27 if the difference between k and n is small, a great number of trees will need
28 to be created to find the solutions
29 if k << n, the solution is easily arrived at.
30
31 So, if k !< n, trees will be removed due to overflow. There is a dependence
32 upon k here. (well k/n to be sure).
33
34 Also:
35 if every element of n is greater than the palette size, there can be no sol.
36
37
38 Additionally, if there is one or more solutions, they may be detected early.
39 The entire state tree (minus prunes) doesn't have to be drawn, as we are
40 looking for _any_ set.
41
42 Finally, there is a depedence upon the input set n - beyond the input times
43 rizwank 1.1 at the beginning there is also a 2^n increase in the _possilble_ set size,
44 the three aforementioned tools goal is to reduce that set size dramatically.
45
46
47 Everything aside though, the complexity is defined (at least in big O notation)
48 by the worst case scenario, --- for this problem as a whole (whether via
49 brute search or branch-bound) the O notation is O(2^n)
50
51
52 -Rizwan Kassim
|