@lucifer: yes I get that...I was just saying that after a swap has happened within the while loop ( since x > min(b,d) might have been the case ) , then in the next looping within while, break wud happen right? meaning it doesnt stay in the while after a swap happens...
On Sun, Jan 22, 2012 at 3:25 PM, Lucifer <[email protected]> wrote: > @Arun > > If you read the post in which i have explained the process properly, > the following is also present: > > while(1) > { > If x <= min (b,d ), > /* here b is nothing but the element placed next to 'x' on the same > row.. > d is the element placed right below 'x' in the same column... > then we are done...*/ > break; > else > swap ('x', min (b,d)) > } > > If you see in the comments i have mentioned that b and d are not > exactly the same b and d as shown in the matrix.. but they are current > right and current bottom elements of 'x'.. > Hence, the swaps go on till the condition " x <= min (b,d ) " is not > satisfied.. > > > > On Jan 23, 3:44 am, Arun Vishwanathan <[email protected]> wrote: > > @lucifer:nice explanation !... just to make a small clarification, in > your > > stabilisation part u jus compare x with min (b,d) , make a swap if > > necessary and then next time u compare it shud be <=min(b,d) and so u > > break. > > > > x b c > > > > d e f > > > > g h i > > > > so now after breaking x is less than both b and d but present b could be > > greater than e right? for example initally it cud be > > 8 5.... > > 6 7..... > > . > > . > > . > > and we swap 8 and 5....now 8 is above 7 after swap ...but is this taken > > care of next iteration when we do swaps of a[row][col] with a[row+1][0]?? > > so is heapify sep in all just comparison of x with b and d only and swap > if > > needed?? > > > > > > > > > > > > > > > > > > > > On Sat, Jan 14, 2012 at 1:48 AM, Gaurav Kalra <[email protected]> wrote: > > > Bases on algorithm suggested by Lucifer, I have coded the problem in C > > > (please see attachment). > > > > > The code has been tested against the following test cases: > > > > > 1 3 4 8 9 > > > 2 5 18 25 50 > > > 6 7 22 45 55 > > > > > and > > > > > 1 2 7 > > > 3 5 8 > > > 4 6 9 > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To view this discussion on the web visit > > >https://groups.google.com/d/msg/algogeeks/-/kQ0gKL_2h7oJ. > > > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > For more options, visit this group at > > >http://groups.google.com/group/algogeeks?hl=en. > > > > -- > > "People often say that motivation doesn't last. Well, neither does > bathing > > - that's why we recommend it daily." > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- "People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily." -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
