Click here to Skip to main content
15,889,992 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Scheduling with constraints Pin
Richard MacCutchan3-Nov-23 6:40
mveRichard MacCutchan3-Nov-23 6:40 
GeneralRe: Scheduling with constraints Pin
jedraw3-Nov-23 6:55
jedraw3-Nov-23 6:55 
GeneralRe: Scheduling with constraints Pin
Richard MacCutchan3-Nov-23 7:06
mveRichard MacCutchan3-Nov-23 7:06 
QuestionRound-robin tournament scheduling, with teams that may share their home field Pin
Mad Bat30-Oct-23 7:00
Mad Bat30-Oct-23 7:00 
AnswerRe: Round-robin tournament scheduling, with teams that may share their home field Pin
Gerry Schmitz30-Oct-23 7:25
mveGerry Schmitz30-Oct-23 7:25 
QuestionAlgorithm Sequence Programming Competition Pin
Member 1612077221-Oct-23 3:38
Member 1612077221-Oct-23 3:38 
AnswerRe: Algorithm Sequence Programming Competition Pin
Gerry Schmitz21-Oct-23 7:42
mveGerry Schmitz21-Oct-23 7:42 
AnswerRe: Algorithm Sequence Programming Competition Pin
Mircea Neacsu21-Oct-23 12:26
Mircea Neacsu21-Oct-23 12:26 
There is a bit of extra information in the problem. Maybe they didn't count well the number of equations and unknowns. You have k+1 unknowns (a[1],...a[k] and d) and k+2 equations. We can take only the first k+1 equations and leave the last one for verification. Here is the math:

We can write n[x] as a polynomial with unknown coefficients c[1] to c[k]:
n[x]=x^k + c[1]*x^(k-1)+c[2]*x^(k-2)...+c[k]
We know the values of this polynomial in each of the points 1, 2,...k+1 so we can write the following system of k+1 equations:
1^k + 1^(k-1)*c[1]+...+c[k] = n[1]*d
2^k + 2^(k-1)*c[1]+...+c[k] = n[2]*d
....
k^k + k^(k-1)*c[1]+...+c[k] = n[k]*d
(k+1)^k + (k+1)^(k-1)*c[1]+...+c[k] = n[k+1]*d
Reordering terms, this gives:
-n[1]*d + 1^(k-1)*c[1]+...+c[k] = -1^k
-n[2]*d + 2^(k-1)*c[1]+...+c[k] = -2^k
....
-n[k]*d + k^(k-1)*c[1]+...+c[k] = -k^k
-n[k+1]*d + (k+1)^(k-1)*c[1]+...+c[k] = -(k+1)^k

This is a system of k+1 equations with k+1 unknown that can be solved:
| d  |
|c[1]|
|... | = M^-1 * V
|c[k]|
where M is the coefficients matrix:
-n[1]     1^(k-1) ... 1
-n[2]     2^(k-1) ... 1
...
-n[k+1] (k+1)^(k-1)...1
and V is the free terms vector:
-1^k
-2^k
...
-(k+1)^k
After you've calculated the coefficients finding the value of the polynomial is trivial.

Here is a numerical example for the case k=2
   |-1 1 1 |    |-1|
M= |-4 2 1 | V= |-4|
   |-6 3 1 |    |-9|
after calculating the inverse of M, the end result is d=2 c[1] = 1 c[2] = 0 and the polynomial is n[x] = x^2+ 1*x + 0. n[4]/2 = (16+4)/2 = 10 (matching the extra equation given) and n[5]/2 = (25+5)=15 matching the suggested answer.
Mircea

GeneralRe: Algorithm Sequence Programming Competition Pin
Member 1612077221-Oct-23 16:58
Member 1612077221-Oct-23 16:58 
AnswerRe: Algorithm Sequence Programming Competition Pin
Mircea Neacsu21-Oct-23 19:48
Mircea Neacsu21-Oct-23 19:48 
GeneralRe: Algorithm Sequence Programming Competition Pin
Gerry Schmitz22-Oct-23 9:05
mveGerry Schmitz22-Oct-23 9:05 
QuestionCollision Response in a RTS game, still trying to figure it out. Pin
Calin Negru23-Sep-23 7:32
Calin Negru23-Sep-23 7:32 
AnswerRe: Collision Response in a RTS game, still trying to figure it out. Pin
Gerry Schmitz23-Sep-23 7:48
mveGerry Schmitz23-Sep-23 7:48 
GeneralRe: Collision Response in a RTS game, still trying to figure it out. Pin
Calin Negru23-Sep-23 22:21
Calin Negru23-Sep-23 22:21 
AnswerRe: Collision Response in a RTS game, still trying to figure it out. Pin
Member 1614278528-Nov-23 6:53
Member 1614278528-Nov-23 6:53 
AnswerRe: Does D correctly simulated by H terminate normally? Pin
Richard MacCutchan16-May-23 22:05
mveRichard MacCutchan16-May-23 22:05 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Richard Deeming16-May-23 22:52
mveRichard Deeming16-May-23 22:52 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Dave Kreskowiak17-May-23 3:18
mveDave Kreskowiak17-May-23 3:18 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Dave Kreskowiak17-May-23 4:07
mveDave Kreskowiak17-May-23 4:07 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Dave Kreskowiak17-May-23 6:22
mveDave Kreskowiak17-May-23 6:22 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Dave Kreskowiak17-May-23 6:35
mveDave Kreskowiak17-May-23 6:35 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Dave Kreskowiak17-May-23 6:44
mveDave Kreskowiak17-May-23 6:44 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
Dave Kreskowiak17-May-23 6:54
mveDave Kreskowiak17-May-23 6:54 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
jschell18-May-23 5:57
jschell18-May-23 5:57 
GeneralRe: Does D correctly simulated by H terminate normally? Pin
jschell19-May-23 7:36
jschell19-May-23 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.