Re: [algogeeks] coloring problem Dynamic programming

2013-12-28 Thread Saurabh Paliwal
@atul your understanding of my recurrences are fine but of the question are not. You cannot have 3 adjacent houses with same colour. GGY is a fine case for this problem. On 28 Dec 2013 20:44, "atul anand" wrote: > @saurabh : i did not get your algo for modified ques i.e "No 3 adjacent > houses sh

Re: [algogeeks] coloring problem Dynamic programming

2013-12-28 Thread atul anand
@saurabh : i did not get your algo for modified ques i.e "No 3 adjacent houses should get same color" according to your recurrence answer[i][j][1] = min(answer[i-1][t][0],answer[i-1][t][1]) + colorvalue[j] for all t from 1 to k except j. now suppose in some case *answer[i-1][t][0] *is found min

Re: [algogeeks] coloring problem Dynamic programming

2013-12-26 Thread kumar raja
Good solution buddy, thanks for the answer. On 26 December 2013 17:25, Saurabh Paliwal wrote: > @atul anand :- no, we need not use all the colors. > > @kumar raja :- sorry dude for replying this late. Continuing with the > previous idea, I extend the solution for the modified problem as > > 1. l

Re: [algogeeks] coloring problem Dynamic programming

2013-12-26 Thread Saurabh Paliwal
@atul anand :- no, we need not use all the colors. @kumar raja :- sorry dude for replying this late. Continuing with the previous idea, I extend the solution for the modified problem as 1. let answer[i][j][0] represent minimum cost of coloring i houses when ith house is colored with jth color and

Re: [algogeeks] coloring problem Dynamic programming

2013-12-18 Thread atul anand
@kumar : i have one doubt regarding this question.Do we have to use all K colors[K] to color all building. for example :- color[3]={1,2,10}; now if we have to color 6 building then i can use only 1st 2 color to color all building and never 10 ...is this allowed ??? building[N]={1,2,1,2,1,2} O

Re: [algogeeks] coloring problem Dynamic programming

2013-12-17 Thread atul anand
ohh shoots...my bad.got this condition wrong "t varies from 1 to k except j." now got it :)..ignore my previous comment :) :) On Tue, Dec 17, 2013 at 11:47 PM, atul anand wrote: > @saurabh : > > answer[i][j] = min(answer[i-1][t]) + colorvalue[t] where t varies from 1 > to k except j. > > h

Re: [algogeeks] coloring problem Dynamic programming

2013-12-17 Thread atul anand
@saurabh : answer[i][j] = min(answer[i-1][t]) + colorvalue[t] where t varies from 1 to k except j. how this DP is taking care of the case where no adjacent house if of same color. what i understand from the DP is the following :- find minimum cost of coloring previous house with color t ( min(a

Re: [algogeeks] coloring problem Dynamic programming

2013-12-17 Thread kumar raja
Please elaborate the explanation, i want to understand it in detail. On 17 December 2013 11:36, Saurabh Paliwal wrote: > I think that can be done by having 2 different values at every position in > the answer matrix. One when the previous house is of same color and one > when it does not. Answer

Re: [algogeeks] coloring problem Dynamic programming

2013-12-16 Thread Saurabh Paliwal
I think that can be done by having 2 different values at every position in the answer matrix. One when the previous house is of same color and one when it does not. Answer[n][k][2] will be the new dimensions. I can explain in detail if you don't get this. ☺ On Dec 15, 2013 4:43 PM, "kumar raja" w

Re: [algogeeks] coloring problem Dynamic programming

2013-12-15 Thread kumar raja
What can be the recurrence relation if the condition is changed to "No 3 adjacent houses should get same color"? On 15 December 2013 16:26, kumar raja wrote: > No need for the explanation ,got it man thanks. > > > On 15 December 2013 16:20, kumar raja wrote: > >> Saurabh your solutions seems r

Re: [algogeeks] coloring problem Dynamic programming

2013-12-15 Thread kumar raja
No need for the explanation ,got it man thanks. On 15 December 2013 16:20, kumar raja wrote: > Saurabh your solutions seems right , but can u explain me how did u arrive > at the time and space complexity with some proof /pseudocode/ explanation? > > > On 15 December 2013 09:47, Saurabh Paliwal

Re: [algogeeks] coloring problem Dynamic programming

2013-12-15 Thread kumar raja
Saurabh your solutions seems right , but can u explain me how did u arrive at the time and space complexity with some proof /pseudocode/ explanation? On 15 December 2013 09:47, Saurabh Paliwal wrote: > what is the issue with the usual recurrence :- > > Let answer[i][j] represent minimum cost of

Re: [algogeeks] coloring problem Dynamic programming

2013-12-14 Thread Saurabh Paliwal
what is the issue with the usual recurrence :- Let answer[i][j] represent minimum cost of coloring i houses with ith house colored with jth color. answer[i][j] = min(answer[i-1][t]) + colorvalue[t] where t varies from 1 to k except j. initial setting :- answer[1][j] = colorvalue[j] final answe

[algogeeks] coloring problem Dynamic programming

2013-12-14 Thread kumar raja
You have 'n' houses and 'k' colors. The cost of coloring a house with one of the 'k' colors is different from coloring another house with same color. The cost of coloring the house with different colors are different. So now how to colour the 'n' houses such that no two adjcent houses will get the