in reply to Re: Brute force vs algorithm (PWC # 100)
in thread Brute force vs algorithm (PWC # 100)
any approach recording paths will fail in general, because there is no guaranty for a unique or even small number of optimal solutions.
Just imagine a triangle with n=100 rows but only weight 1 in every cell, the number of optimal paths is 2**99 then and the weight is always 100.
But it's nonetheless possible to calculate the weight of the optimal path, and even to reconstruct one of those optimal path.
And this in at most n**2/2 (here ~5000) steps (time and space complexity)
see Re^2: Brute force vs algorithm (PWC # 100)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Brute force vs algorithm (PWC # 100)
by tybalt89 (Monsignor) on Feb 16, 2021 at 00:14 UTC | |
by LanX (Saint) on Feb 16, 2021 at 03:42 UTC | |
by tybalt89 (Monsignor) on Feb 16, 2021 at 04:39 UTC | |
by tybalt89 (Monsignor) on Feb 16, 2021 at 05:04 UTC |