Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread sunny agrawal
i am Considering given heap as min heap Sol - because heap has property that root will has lower value than all the elements in its left sub tree and right sub tree so in main we will call a function passing root and value k and x if at any time root is greater than x and k 0 that means rest of

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread atul anand
@sunny : this will work :) On Wed, Dec 14, 2011 at 4:08 PM, sunny agrawal sunny816.i...@gmail.comwrote: i am Considering given heap as min heap Sol - because heap has property that root will has lower value than all the elements in its left sub tree and right sub tree so in main we will

[algogeeks] Re: Nice question

2011-12-14 Thread Lucifer
Just solved it.. The approach is same as Don's but starting from the front... Hence, penning it down.. Let F(i) be defined as the no. of integers that are possible to be formed using the first 'i' integral differences.. Then F(i+1) = No. of integers from set F(i) where the units place = 'i +1'

[algogeeks] Re: Dynamic programming question

2011-12-14 Thread Gene
Longest path won't work so well because it will return infinity if a path contains a positive cycle, which doesn't apply here because once you pick up an apple, it's gone. On Dec 13, 7:17 am, vikas vikas.rastogi2...@gmail.com wrote: Graph take up, right  and bottom as nodes connected to current

[algogeeks] Re: Best algorithm possible

2011-12-14 Thread Lucifer
@atul anand I am guessing that you referring to the the n^2 solution.. if yes, then no i am not considering all permutations... Basically L(i) is the reordering of A[i] which depicts the largest no. that can be formed when read from left to right i.e MSD to LSD... Hence, L(i+1) can be found by

Re: [algogeeks] Re: Dynamic programming question

2011-12-14 Thread Azhar Hussain
We need not necessarily pick the apple. We need to suggest a way that could have maximum apples and path need not be longest. Another person will follow our path and pick the apples. we can start from specified (i,j) and have to reach specified (i, n) traversing either top, right, down(not left).

[algogeeks] Re: Best algorithm possible

2011-12-14 Thread Lucifer
@dipit Its not really a strict comparison.. To sort all we are doing is, keeping in mind that all the elements are integers, is as follows: Say, we need to sort two elements.. A and B i = no. of digits in A, i.e Log10 (A) j = no. of digits in B, i.e Log10 (B) k = min (i, j); x1 = A / pow(10,

[algogeeks] Complexity

2011-12-14 Thread Shashank Jain
I need to study both space and time complexities. What is the best source? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] convert into palindrome

2011-12-14 Thread top coder
Given a word, convert it into a palindrome with minimum addition of letters to it. letters can be added anywhere in the word. . for eg if hello is given, result should be hellolleh -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

[algogeeks] Re: Dynamic programming question

2011-12-14 Thread Tryzen
From (a,b) to (c,n) = What about traversing all columns n = j = a as we can move up-down-right anytime we want. On Dec 14, 5:57 pm, Azhar Hussain azhar...@gmail.com wrote: We need not necessarily pick the apple. We need to suggest a way that could have maximum apples and path need not be

Re: [algogeeks] Re: Best algorithm possible

2011-12-14 Thread atul anand
@ Lucifer : so i guess this is what you are trying to say:- input : 2 3 5 78 L(0)= {2) L(1)= {2,3} , {3,2} {3,2} is greatest L(2)= {3,2,5} , { 3,5,2 } , {5,3,2 } {5,3,2} is the greatest L(3)= {5,3,2,78} , {5,3,78,2} , {5,78,3,2 } , {78,5,3,2} {78,5,3,2} found nice :) On

[algogeeks] Re: Best algorithm possible

2011-12-14 Thread Lucifer
@atul... yup u r right... There is a faster app. that i have mentioned i.e. O(nlogn)... On Dec 14, 10:02 pm, atul anand atul.87fri...@gmail.com wrote: @ Lucifer : so i guess this is what you are trying to say:- input : 2 3 5 78 L(0)= {2) L(1)= {2,3} , {3,2}   {3,2} is greatest

Re: [algogeeks] convert into palindrome

2011-12-14 Thread Mohit kumar lal
@saurabh-as by the above example LCS of HELLO and its inverse would be LL and how can we form the word HELLOLLEH with it ... and is your ans for the word NITAN is NITATIN ...? On Wed, Dec 14, 2011 at 8:39 PM, saurabh singh saurab...@gmail.com wrote: Find the LCS of string with its reverse

[algogeeks] Re: convert into palindrome

2011-12-14 Thread Lucifer
@Mohit I think what he meant is 2* strlen(Input String) - 2* (Length of LCS) On Dec 15, 3:44 am, Mohit kumar lal kumarmohit...@gmail.com wrote: @saurabh-as by the above example LCS of HELLO and its inverse would be LL and how can we form the word HELLOLLEH with it ... and is your ans for the

Re: [algogeeks] Complexity

2011-12-14 Thread saurabh singh
Introduction to Algorithms Coreman On Wed, Dec 14, 2011 at 8:21 PM, Shashank Jain shashan...@gmail.com wrote: I need to study both space and time complexities. What is the best source? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] doubt in TSUM

2011-12-14 Thread anubhav raj
hey guys ,i am trying to solve TSUM ..on spoj... http://www.spoj.pl/problems/TSUM/.in which we have to find the sum of any triplets in n numbers.can any one suggests me any approach other than brute-force of (n^3).. ..thanks in advance --

[algogeeks] Re: convert into palindrome

2011-12-14 Thread top coder
@Mohit Suppose for example String: NITAN LCS(Longest Common Subsequence) : NIN How do you get the palindrome with it? On Dec 15, 3:47 am, Lucifer sourabhd2...@gmail.com wrote: @Mohit I think what he meant is 2* strlen(Input String) - 2* (Length of LCS) On Dec 15, 3:44 am, Mohit kumar

[algogeeks] Re: convert into palindrome

2011-12-14 Thread Lucifer
@All, I would like to correct a mistake in my previous post.. The min no. of additions = strlen(Input String) - (Length of LCS) On Dec 15, 11:24 am, top coder topcode...@gmail.com wrote: @Mohit Suppose for example String: NITAN LCS(Longest Common Subsequence) : NIN How do you get the

[algogeeks] Re: convert into palindrome

2011-12-14 Thread Lucifer
Correction: for NAN : N(IT)A + TI + N = NITATIN On Dec 15, 11:33 am, Lucifer sourabhd2...@gmail.com wrote: @topcoder.. String: NITAN RevStr: NATIN LCS ( NITAN, NATIN) = { NIN , NAN } Here all we care about the count which is 2. Hence, 2 additions would be required to convert it into a

[algogeeks] Re: find numbers if pair wise sums are given

2011-12-14 Thread WgpShashank
@all , a Naive Approach with Quadratic Time will be for each i=1 to n , check if i and a[i]-i makes given sum , so for each each number we will do the thus can achieve the solution ...i am just thinking about if we can do it linear time ..will post if able to do it :) Thanks Shashank CSe BIT

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread WgpShashank
@sunny it will 3k not 2k ? u forgot to count the root element so over all time complexity will O(3K)=O(K) correct me if am wrong ? Thanks Shashank Mani CSE, BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread WgpShashank
more clarification , why number of comparisons are 3k , because we are looking for only those nodes which are less then x and each nodea can max 2 childs , so tottal 3k comparisons . so it will O(3K) . Thanks Shashank CSE , BIT Mesra -- You received this message because you are subscribed

[algogeeks] Re: doubt in TSUM

2011-12-14 Thread WgpShashank
@anubhaw ..check wiki for O(N^2) algorithm ..u will get the logic Thanks Shashank Mani CSE , BIT Mesra http://shashank7s.blogspot.com/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] Re: Suggest Algo for this Question

2011-12-14 Thread sunny agrawal
@shashank nope only 2k comparisions k numbers which are greater than x and k which are less than x dont think in terms of root and child On Thu, Dec 15, 2011 at 12:57 PM, WgpShashank shashank7andr...@gmail.comwrote: more clarification , why number of comparisons are 3k , because we are looking

[algogeeks] Re: Dynamic programming question

2011-12-14 Thread WgpShashank
@Azhar , 1st Try to formulate the recursive relation , then draw recursive tree , then u willl know why it need DP to solve efficiently , then u can memozation to solve the same . Hope it help. Thanks Shashank Mani CSE ,BIT Mesra http://shashank7s.blogspot.com/ -- You received this

[algogeeks] Re: Dynamic programming question

2011-12-14 Thread WgpShashank
@Azhar , also for 1st question u r trying Array DS will suffices. Its Standard Coin Change Problem , u need to solve subproblem 1st , store it in extra array to avoid recalculation , if u are able to produce the sum less given sum then u can use same approach to reach desired sum . it uses the

Re: [algogeeks] Re: doubt in TSUM

2011-12-14 Thread anubhav raj
HEY DUDE TNX FOR THE REPLY .CAN YOU PASTE ME THE LINK FOR THAT WIKI PAGE. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send