Re: [algogeeks] Re: Take 5 digit number and find 2 power that number.............

2010-09-01 Thread Yan Wang
Maybe you misunderstand the question. The question is how to compute 2^X where 0 <= X <= 9? How? On Wed, Sep 1, 2010 at 10:48 PM, Ruturaj wrote: > a 5 digit number is of order 10^5 which is << 10^16 of which int in C > is of size. > Just multiply both numbers. > > On Sep 2, 10:39 am, pras

[algogeeks] Re: Take 5 digit number and find 2 power that number.............

2010-09-01 Thread Ruturaj
a 5 digit number is of order 10^5 which is << 10^16 of which int in C is of size. Just multiply both numbers. On Sep 2, 10:39 am, prasad rao wrote: > Program that takes a 5 digit number and calculates 2 power that number and > prints it and should not use the Big-integer and Exponential Function'

[algogeeks] Take 5 digit number and find 2 power that number.............

2010-09-01 Thread prasad rao
Program that takes a 5 digit number and calculates 2 power that number and prints it and should not use the Big-integer and Exponential Function's. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...

Re: [algogeeks] Re: find duplicate and missing element

2010-09-01 Thread Dhritiman Das
@Dinesh, Yes, we can't apply this method, if that's not allowed. On Thu, Sep 2, 2010 at 10:31 AM, dinesh bansal wrote: > > > On Wed, Sep 1, 2010 at 11:08 AM, Dhritiman Das wrote: > >> >> Given a array, A[1..n], do the following. >> Start from i=1 and try placing each number in its correct positi

Re: [algogeeks] Re: find duplicate and missing element

2010-09-01 Thread dinesh bansal
On Wed, Sep 1, 2010 at 11:08 AM, Dhritiman Das wrote: > > Given a array, A[1..n], do the following. > Start from i=1 and try placing each number in its correct position in the > array. > If the number is already in its correct position, go ahead. if (A[i] == i) > , i++ > else if the number was alr

[algogeeks] Re: find duplicate and missing element

2010-09-01 Thread Dave
@Raj: It is just algebra. Dave On Sep 1, 11:50 am, Raj Jagvanshi wrote: > in ur algo i confuse in solving eqn > > > > On Wed, Sep 1, 2010 at 6:31 PM, Dave wrote: > > @Raj: Best what? > > > Dave > > > On Sep 1, 12:08 am, Raj Jagvanshi wrote: > > > Thanks Dave > > > but i want best > > > > On We

[algogeeks] Re: find duplicate and missing element

2010-09-01 Thread luckyzoner
According to me we can apply the equatin method : Let the missing number be y. Let the duplicated no. be x. 1. then find the product of the 1 to 100 and the sum 1 to 100 :A Product would be of the form...1 *2*3x*..y*100 : B Sum : 1+2+3.+x+y.+100 2. find the prduct

Re: [algogeeks] Re: find duplicate and missing element

2010-09-01 Thread Anand
1. First find the sum of all given elements.: sum 2. find the sum of elements in the given range. : sum_1 3. Find the duplicates.: d 4. Missing Number: sum-sum_1+d. http://codepad.org/77Nr9Hay On Wed, Sep 1, 2010 at 9:50 AM, Raj Jagvanshi wrote: > in ur algo i conf

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-09-01 Thread Gene
Okay. First, you can make the DP more efficient than the one I gave earlier. You don't need to scan the whole previous column when calculating costs of decrementing. Rather there are only two possibilities. I will add that rahul patil's solution looks correct, but it's exponential time. DP is b

[algogeeks] Re: Amazon intern Question

2010-09-01 Thread Gene
Even if you're only matching words, there are different kinds of similarity. Check out the soundex algorithm, for example. Levenshtein distance. The Hungarian algorithm. What does "50% similarity" mean anyway? I know of no accepted meaning. My point is that if you're in an interview situation

Re: [algogeeks] Amazon intern Question

2010-09-01 Thread Chakravarthi Muppalla
@Gene, it isn't about related words, its abt matching words! On Wed, Sep 1, 2010 at 8:26 PM, saurabh singh wrote: > I think DS will be somewhere between suffix and trie DS > > > On Wed, Sep 1, 2010 at 9:35 AM, jaladhi dave wrote: > >> trie >> >> On Wed, Sep 1, 2010 at 5:45 PM, Arun wrote: >> >>>

Re: [algogeeks] Re: Subsequence

2010-09-01 Thread Nikhil Jindal
Very Nice soln Dhritiman. The solution to the standard LCS problem only needs O(n^2) time and O(n) space. And you have very intelligently solved its variation also in the same time and space complexity. I fell this is the correct solution. Nikhil Jindal On Tue, Aug 31, 2010 at 2:13 AM, Dhritiman

Re: [algogeeks] Re: find duplicate and missing element

2010-09-01 Thread Raj Jagvanshi
in ur algo i confuse in solving eqn On Wed, Sep 1, 2010 at 6:31 PM, Dave wrote: > @Raj: Best what? > > Dave > > On Sep 1, 12:08 am, Raj Jagvanshi wrote: > > Thanks Dave > > but i want best > > > > > > > > On Wed, Sep 1, 2010 at 7:14 AM, Dave wrote: > > > Suppose that x is duplicated and y is o

Re: [algogeeks] Amazon intern Question

2010-09-01 Thread saurabh singh
I think DS will be somewhere between suffix and trie DS On Wed, Sep 1, 2010 at 9:35 AM, jaladhi dave wrote: > trie > > On Wed, Sep 1, 2010 at 5:45 PM, Arun wrote: > >> You are given the amazon.com database which consists of names of >> millions of products. When a user enters a search query for

Re: [algogeeks] Amazon intern Question

2010-09-01 Thread Chakravarthi Muppalla
I guess, you should be using a suffix tree. On Wed, Sep 1, 2010 at 5:45 PM, Arun wrote: > You are given the amazon.com database which consists of names of > millions of products. When a user enters a search query for particular > object with the keyword say "foo" , output all the products which

[algogeeks] Re: call google search from a java program

2010-09-01 Thread Minotauraus
http://code.google.com/apis/ajaxsearch/web.html It is possible to use this with Java. On Aug 31, 9:42 pm, Debajyoti Sarma wrote: > Hi , > I am working on a project where i need to call Google search form a > Java servlet program.1 string containing the query is supposed to pass > to the Google se

Re: [algogeeks] Subsequence

2010-09-01 Thread Shaswat Nimesh
U can choose the linear search option for it ,then arrange the it according to the priority of the numbers and so on Sent from my iPod On Aug 25, 2010, at 9:31 PM, Raj N wrote: > @Rahul: Input: 5 4 6 7 3 2 9 8 and if k=3 > should the output be 4+6+7=11 ? Is that what you mean by non-decreasin

Re: [algogeeks] Amazon intern Question

2010-09-01 Thread jaladhi dave
trie On Wed, Sep 1, 2010 at 5:45 PM, Arun wrote: > You are given the amazon.com database which consists of names of > millions of products. When a user enters a search query for particular > object with the keyword say "foo" , output all the products which have > names having 50% or more similar

Re: [algogeeks] Could anyone explain how this code works?????????!!!!

2010-09-01 Thread Terence
Simple run-length encoding of a ascii picture. On 2010-9-1 3:49, Albert wrote: #include main() { int a,b,c; int count = 1; for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\ TFy!QJu ROo TNn(ROo)SLq SLq ULo+\ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\ NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\ HCStHAUFAgcEAelclcn^r^

[algogeeks] Re: Amazon intern Question

2010-09-01 Thread Gene
Edit distance is one way to determine similarity. It assumes all differences are typographic. Amazon is probably interested in many other forms of similarity. When someone types "audio system" in the Amazon search, you want them to see receivers, speakers, tuners, etc. It's very possible this qu

[algogeeks] Re: call google search from a java program

2010-09-01 Thread Gene
Google provides many APIs that are fairly well-documented: http://code.google.com/more/ Make sure to read the licence requirements. On Sep 1, 12:42 am, Debajyoti Sarma wrote: > Hi , > I am working on a project where i need to call Google search form a > Java servlet program.1 string containing

Re: [algogeeks] Re: find duplicate and missing element

2010-09-01 Thread dinesh bansal
can you explain on your algorithm. Are you using any extra array. On Wed, Sep 1, 2010 at 11:08 AM, Dhritiman Das wrote: > > Given a array, A[1..n], do the following. > Start from i=1 and try placing each number in its correct position in the > array. > If the number is already in its correct posi

[algogeeks] Re: Amazon intern Question

2010-09-01 Thread jagadish
HI Arun, This is the edit distance problem which can be solved using DP. Calculate the cost for each product on the fly and return the top products with the least edit cost! On Sep 1, 5:15 pm, Arun wrote: > You are given the amazon.com database which consists of names of > millions of products.

[algogeeks] Re: find duplicate and missing element

2010-09-01 Thread Dave
@Raj: Best what? Dave On Sep 1, 12:08 am, Raj Jagvanshi wrote: > Thanks Dave > but i want best > > > > On Wed, Sep 1, 2010 at 7:14 AM, Dave wrote: > > Suppose that x is duplicated and y is omitted. Then the sum of the > > numbers would be 5050 + x - y. Similarly, the sums of the squares of > >

[algogeeks] Amazon intern Question

2010-09-01 Thread Arun
You are given the amazon.com database which consists of names of millions of products. When a user enters a search query for particular object with the keyword say "foo" , output all the products which have names having 50% or more similarity with the given keyword ie "foo" Write the most efficien

Re: [algogeeks] Re: ternary numbers

2010-09-01 Thread Terence
Or directly get the last digits from (-1, 0, 1) 100 = 33 * 3 + 1 33 = 11 * 3 + 0 11 = 4 * 3 + (-1) 4 = 1 * 3 + 1 1 = 0 * 3 + 1 Collect those digits together, we get 11X01_3 On 2010-8-31 23:40, Dave wrote: 352/9 = 39-1/9 = 27 + 9 + 3 + 1/9 = 1*3^3 + 1*3^2 + 1*3^1 + 0*3^0 + 0*3^

[algogeeks] call google search from a java program

2010-09-01 Thread Debajyoti Sarma
Hi , I am working on a project where i need to call Google search form a Java servlet program.1 string containing the query is supposed to pass to the Google search engine and results must display through my program .I am also trying to copy the top results and some text(first 2-3 lines what Google

Re: [algogeeks] Re: find duplicate and missing element

2010-09-01 Thread Raj Jagvanshi
Thanks Dave but i want best On Wed, Sep 1, 2010 at 7:14 AM, Dave wrote: > Suppose that x is duplicated and y is omitted. Then the sum of the > numbers would be 5050 + x - y. Similarly, the sums of the squares of > the numbers would be 338,350 + x^2 - y^2. Calculate the sum and sum of > squares o