[algogeeks] Longest simple path problem

2011-06-27 Thread ankit sambyal
Shortest simple path problem is in P, but Longest simple path problem is in NP. Explain why the greedy choice(on edge weights) is not suitable in the second case . Ankit Sambyal BITS Pilani -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. T

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread kartik sachan
@VAIBHAV.ur logic fails in many cases...like G -- 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 g

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread kartik sachan
GOT AC IN .02 SEC .:))) -- 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+unsubscr...@googleg

Re: [algogeeks] Printing unique rows.

2011-06-27 Thread sunny agrawal
@Ankit if N is large how will you hash the rows, numbers will be very large can you explain using given example ? On Tue, Jun 28, 2011 at 11:38 AM, Ankit Agrawal < ankitmnnit.agra...@gmail.com> wrote: > u can use hashing ... > hash fun can b "base2 to base10" > > -- > You received this message b

Re: [algogeeks] Printing unique rows.

2011-06-27 Thread Piyush Sinha
In any case, I don't think the complexity can be improved from O(n^2) because even in creating hash function every column element of every row which itself is N^2 only.. On Tue, Jun 28, 2011 at 11:38 AM, Ankit Agrawal < ankitmnnit.agra...@gmail.com> wrote: > u can use hashing ... > hash fun can b

Re: [algogeeks] Printing unique rows.

2011-06-27 Thread Ankit Agrawal
u can use hashing ... hash fun can b "base2 to base10" -- 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+unsubscr...@googl

Re: [algogeeks] Printing unique rows.

2011-06-27 Thread sunny agrawal
if N <= 64 then we can convert all rows in an equivalent integer and then sort all numbers and print distinct No.s else Worst case Solution would be to to check for each pair of rows and match - O(N^3) one more solution i can think of is to divide and conquer solution which goes like this based o

[algogeeks] Printing unique rows.

2011-06-27 Thread oppilas .
Given a binary matrix of N X N of integers , you need to return only unique rows of binary arrays eg: 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 ans: 0 1 0 0 1 1 0 1 1 0 1 1 1 0 0 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this

[algogeeks] Re: PUZZLE

2011-06-27 Thread Dave
Replying to myself, I should have printed i*i instead of i near the end of the code: printf("%i\n",i*i); Dave On Jun 27, 11:47 pm, Dave wrote: > @Bhavesh: Check the squares of the integers from > ceiling(sqrt(123456789)) to floor(sqrt(987654321)) to see which ones > contain all nine nonzero digi

[algogeeks] Re: PUZZLE

2011-06-27 Thread Dave
@Bhavesh: Check the squares of the integers from ceiling(sqrt(123456789)) to floor(sqrt(987654321)) to see which ones contain all nine nonzero digits. Since the sum of the nine nonzero digits is 45, a satisfactory square will be a multiple of 9, and therefore, we only need consider the squares of i

Re: [algogeeks] Re: Sherlock puzzle 24 June

2011-06-27 Thread sagar pareek
It was due to finish of oxygen inside the car.as it was sealed with closed door and windows On Sat, Jun 25, 2011 at 8:59 PM, sarveswaran v wrote: > she might have died because of heat generated inside the closed car > > On Jun 24, 3:05 am, Lavesh Rawat wrote: > > *sherlock puzzle Solution -

[algogeeks] PUZZLE

2011-06-27 Thread Bhavesh agrawal
All the nine digits are arranged here so as to form four square numbers: 9 81 324 576 How would you put them together so as to form single smallest possible square number and a single largest possible square number.. 139854276 and 923187456 are the answers given eve

[algogeeks] Queue using a stack

2011-06-27 Thread Ashish Goel
Hi, The implementation is simple using 2 stacks, however we also need to make sure that if queue length is say x, we are able to enqueue x elements. As per my understanding, i could think of the solution using 4 stacks instead of 2(1 for enqueue, 1 for dequeue, 1 aux for enqueue, 1 aux for dequeue

Re: [algogeeks] Re: Statement Riddle

2011-06-27 Thread varun pahwa
*'Ferari driver' easily beats the 'force indain driver'.* *'force indain drive' had outdone the 'ferari driver'. Now second statement says force indian drive outdone the ferari driver (who is a man who must have run/walked).* On Mon, Jun 27, 2011 at 9:09 AM, Vishal Thanki wrote: > this may be a

Re: [algogeeks] Re: O(n) Time is the problem. ..

2011-06-27 Thread Anand
http://anandtechblog.blogspot.com/2011/06/google-question-find-missing-number.html On Mon, Jun 27, 2011 at 4:12 PM, aditya kumar wrote: > > @Kamakshi.thnks.i dint realise that. > > On Mon, Jun 27, 2011 at 11:04 PM, sunny agrawal > wrote: > >> @saket - No >> >> O(n) + O(n/2) + O(n/4)

Re: [algogeeks] Re: O(n) Time is the problem. ..

2011-06-27 Thread aditya kumar
@Kamakshi.thnks.i dint realise that. On Mon, Jun 27, 2011 at 11:04 PM, sunny agrawal wrote: > @saket - No > > O(n) + O(n/2) + O(n/4)... = O(n) > > sum of series > n+n/2+n/4+n/8 = 2n > > > On Mon, Jun 27, 2011 at 9:26 PM, Sanket wrote: > >> @Dave - Wouldn't your soluti

Re: [algogeeks] novel written test

2011-06-27 Thread amit kumar
ok piyush..u r right.well done On Tue, Jun 28, 2011 at 2:31 AM, Piyush Sinha wrote: > We just need to look the 3 set of number that multiply to 36... > > the set can be as > (1,1,36),(1,2,18),(1,4,9)..(1,6,6),(1,3,12)..(2,2,9) > > The catch here is we need not find the whole set..

Re: [algogeeks] novel written test

2011-06-27 Thread amit kumar
how 2?? On Tue, Jun 28, 2011 at 2:40 AM, gmagog...@gmail.com wrote: > > if( links can be melt and made into smaller links ) > { > return 1; > } > else > { > return 2; > } > Yanan Cao > > > > On Mon, Jun 27, 2011 at 4:09 PM, sourabh jakhar > wrote: > >> two >> >> >> On Tue, Jun 28, 2011 a

Re: [algogeeks] novel written test

2011-06-27 Thread gmagog...@gmail.com
if( links can be melt and made into smaller links ) { return 1; } else { return 2; } Yanan Cao On Mon, Jun 27, 2011 at 4:09 PM, sourabh jakhar wrote: > two > > > On Tue, Jun 28, 2011 at 2:23 AM, amit the cool wrote: > >> A chain is broken into three pieces of equal lengths containing 3

Re: [algogeeks] novel written test

2011-06-27 Thread sourabh jakhar
two On Tue, Jun 28, 2011 at 2:23 AM, amit the cool wrote: > A chain is broken into three pieces of equal lengths containing 3 > links each. It is taken to a back smith to join into a single > continuous one . How many links are to be opened to make it ? > > -- > You received this message because

Re: [algogeeks] novel written test

2011-06-27 Thread Piyush Sinha
We just need to look the 3 set of number that multiply to 36... the set can be as (1,1,36),(1,2,18),(1,4,9)..(1,6,6),(1,3,12)..(2,2,9) The catch here is we need not find the whole set...the second mathematician can't guess their ages through their sum that means there are at least two

Re: [algogeeks] novel written test

2011-06-27 Thread gmagog...@gmail.com
Is it required that no two sons have the same age? >From my view, the clue "my youngest is the youngest" only defines the requirement that "the youngest one is unique", but he can still have two older brothers of the same age. Please correct me if this is wrong. Yanan Cao On Mon, Jun 27, 2011

Re: [algogeeks] novel written test

2011-06-27 Thread udit sharma
Since the product of their ages is 36. So the possible combination of ages may b: either 1 4 9 or 4 3 3 6 6 1 1 2 18 1 3 12 1 1 36 2 2 9 Now neighbor's door numbr gives the sum.. Here all gives uniq sum except (sum=13) So there will be doubt in either 6 6 1 or 2 2 9 Bt as mathematician said tat "yo

Re: [algogeeks] novel written test

2011-06-27 Thread amit kumar
@piyush..will u xplain plz. by d way 2 sons cant hav d same age(hope they r nt twins) On Tue, Jun 28, 2011 at 2:14 AM, Piyush Sinha wrote: > 1,6,6 > > > On Tue, Jun 28, 2011 at 2:07 AM, amit the cool wrote: > >> Conversation between two mathematicians: first : I have three >> children. The produc

[algogeeks] novel written test

2011-06-27 Thread amit the cool
A chain is broken into three pieces of equal lengths containing 3 links each. It is taken to a back smith to join into a single continuous one . How many links are to be opened to make it ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

Re: [algogeeks] novel written test

2011-06-27 Thread Piyush Sinha
1,6,6 On Tue, Jun 28, 2011 at 2:07 AM, amit the cool wrote: > Conversation between two mathematicians: first : I have three > children. The product of their ages is 36 . If you sum their ages . it > is exactly same as my neighbor's door number on my left. The second > mathematician verifies the d

[algogeeks] novel written test

2011-06-27 Thread amit the cool
Conversation between two mathematicians: first : I have three children. The product of their ages is 36 . If you sum their ages . it is exactly same as my neighbor's door number on my left. The second mathematician verifies the door number and says that the not sufficient . Then the first says " o.

[algogeeks] Re: NEED ALGO IN TIME 0.00

2011-06-27 Thread Dumanshu
@Rizwan: don't u think for the counting sort part, if u use 11 int array as it is without copying values in the main array, it would run faster? And later on, get the sum from the two 11 int arrays like I did. Although m using a single buffer so m getting 0.01. ->http://ideone.com/lsK8n So, by usin

[algogeeks] SAP Project Manager || San Jose, CA || 6+ months Contract

2011-06-27 Thread Steven Smith
Hi, Please find the following requirement and send me your consultant resume with the following details. Name: Contact: Current Location: Relocation: Rate: Position : SAP Project Manager Location : San Jose, CA Duration : 6+ months Contract * * *SAP PM with Finance modules experience + M+A exp

[algogeeks] Jr QA Analysts || 6 + months Contract || Columbus OH || $26-30/hr on C2C all inc

2011-06-27 Thread Steven Smith
Hi, Please find the following requirement and send me your consultant resume with the following details. Name: Contact: Current Location: Relocation: Rate: Job Title : Jr QA Analysts Duration:6 + months Contract Location : Columbus OH Rate : $26-30/hr on C2C all inc **CANDIDATES L

Re: [algogeeks] Anyone have "The google resume book"

2011-06-27 Thread radha krishnan
+1 :P On Tue, Jun 28, 2011 at 12:27 AM, hary rathor wrote: > very funny ! every one know this site swathi > > -- > 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 unsubscri

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread vaibhav agarwal
@kartik also consider the case of GB the answer is 1 BG. ie trailing G's left. BGB leading B's left hence only one G followed by B therefore only one iteration. try out some cases u will find hw it wrks. On Tue, Jun 28, 2011 at 12:42 AM, vaibhav agarwal < vibhu.bitspil...@gmail.com>

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread vaibhav agarwal
@kartik yup frgt to mention the last case 1 followed by zero's in that case number of iterations is the no. of trailing zeroes. GBGBBB will have four iterations 101000 = 1(one zero b/w two ones) + 3(last 1 followed by 3 zero's) BGBGBB,BBGBGB,BBBGBG,GG well logic is how hw mny jump of 1's u n

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Piyush Sinha
how about converting the BST into a doubly linked list...but this will definitely modify the BST.. On Mon, Jun 27, 2011 at 11:32 PM, Swathi wrote: > Dave, > > I am unable to write code for this so i am asking your help. > > Thanks, > Swathi > > > On Mon, Jun 27, 2011 at 11:28 PM, Dave wrote: >

Re: [algogeeks] Anyone have "The google resume book"

2011-06-27 Thread hary rathor
very funny ! every one know this site swathi -- 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+unsubscr...@googlegroups.co

[algogeeks] c/c++ : STREAM PROBLEM

2011-06-27 Thread hary rathor
if i am design algo which specify to not use the extra memory then if i use the streams . then is it consider as a extra memory? -- Harish Pranami Master Of Computer Application , Deptt of computer Science, north campus , university of delhi, New Delhi pin no - 110007 -- You received this mes

[algogeeks] Re: Yahoo Question

2011-06-27 Thread priyanshu
anyone!!! On Jun 23, 3:28 pm, Priyanshu wrote: > You have 100 computers, connected with each other. Give the most efficient > way to design a web crawler, which will crawl most pages in least amount of > time. > > Thanks, > Priyanshu. -- You received this message because you are subscribed to t

Re: [algogeeks] Reverse

2011-06-27 Thread Swathi
it works perfectly On Mon, Jun 27, 2011 at 11:53 PM, hary rathor wrote: > this solution according to sameer statement solution if there is any > problem then pls tell me . here string or char is not being > store anywhere > > char * reverse(char *str,int i ,int j) > { > while(i { > > str[i]=str

Re: [algogeeks] Reverse

2011-06-27 Thread hary rathor
this solution according to sameer statement solution if there is any problem then pls tell me . here string or char is not being store anywhere char * reverse(char *str,int i ,int j) { while(ihttp://groups.google.com/group/algogeeks?hl=en.

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Swathi
Dave, I am unable to write code for this so i am asking your help. Thanks, Swathi On Mon, Jun 27, 2011 at 11:28 PM, Dave wrote: > @Swathi: No. I think the high level description should be adequate for > you to write your own code or pseudocode, albeit recognizing that you > may have to look up

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Dave
@Swathi: No. I think the high level description should be adequate for you to write your own code or pseudocode, albeit recognizing that you may have to look up how to do an inorder traversal using a stack instead of recursion. Dave On Jun 27, 9:34 am, Swathi wrote: > Dave, > > Can you provide t

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread kartik sachan
HEY DUDE I AM NOT GETTING UR LOGIC AT ALL I THINK HOW U WILL SATISFY THIS CASE GBGBBB -- 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

[algogeeks] Re: MS question

2011-06-27 Thread Dave
@Nishant: Here are a couple of O(n) alternatives, given that there are a limited number of "last characters" and no requirement to break ties in any particular way: 1. A counting sort. 2. Form a linked list of entries corresponding to each last character, and then merge these lists in collating s

Re: [algogeeks] Re: puzzle

2011-06-27 Thread Bhavesh agrawal
ok , yeah 3 is the correct answer .. -- 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+unsubscr...@googlegroups.com. For m

Re: [algogeeks] Re: puzzle

2011-06-27 Thread sunny agrawal
@Bhavesh NO there is No stupity just a mistake in reading the question mice die within 14 hrs.Not exactly 14 hours :) 3 is correct answer. On Mon, Jun 27, 2011 at 10:51 PM, Bhavesh agrawal wrote: > only ONE mouse ...consume each sample of bottles of bear with a difference > of one hour

Re: [algogeeks] Re: O(n) Time is the problem. ..

2011-06-27 Thread sunny agrawal
@saket - No O(n) + O(n/2) + O(n/4)... = O(n) sum of series n+n/2+n/4+n/8 = 2n On Mon, Jun 27, 2011 at 9:26 PM, Sanket wrote: > @Dave - Wouldn't your solution also become O(kn) where k = number of > bits in the number? > In this summation - O(n) + O(n/2) + O(n/4) + .

Re: [algogeeks] Re: puzzle

2011-06-27 Thread Bhavesh agrawal
only ONE mouse ...consume each sample of bottles of bear with a difference of one hour and calculate time.. sry if is thr any stupidity in this answer..but i think it may be right -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post

Re: [algogeeks] Reverse

2011-06-27 Thread sameer.mut...@gmail.com
guys temporary variable means not to store string in another variable. On Mon, Jun 27, 2011 at 10:37 PM, hary rathor wrote: > @vishal : dont you think that , i is also a variable? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > T

Re: [algogeeks] Office Suite

2011-06-27 Thread vaibhav agarwal
@radha k but i think we need to store the bottom of the stack for deleting the last node in O(1). as we can click the redo or undo fixed number of times and we would need two stacks is that ok. On Mon, Jun 27, 2011 at 10:31 PM, radha krishnan < radhakrishnance...@gmail.com> wrote: > You asked the

Re: [algogeeks] Reverse

2011-06-27 Thread hary rathor
@vishal : dont you think that , i is also a variable? -- 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+unsubscr...@google

[algogeeks] MS

2011-06-27 Thread Akshata Sharma
you are given a system of passing binary trees among 2 ppl Step1: convert the tree to preorder and inorder strings Step2:send those strings to the intended person Step3:get back tree from the strings whats your strategy of testing?write various test scenarios. -- You received this message becau

Re: [algogeeks] Office Suite

2011-06-27 Thread radha krishnan
You asked the Most Efficient dude On Mon, Jun 27, 2011 at 10:29 PM, vaibhav agarwal wrote: > @radha: hw abt using a fixed size circular list? > > On Sat, Jun 25, 2011 at 8:25 PM, radha krishnan > wrote: >> >> simple!! >>  Stack:P >> >> On Sat, Jun 25, 2011 at 8:11 PM, rShetty wrote: >> > Sugges

Re: [algogeeks] Office Suite

2011-06-27 Thread vaibhav agarwal
@radha: hw abt using a fixed size circular list? On Sat, Jun 25, 2011 at 8:25 PM, radha krishnan < radhakrishnance...@gmail.com> wrote: > simple!! > Stack:P > > On Sat, Jun 25, 2011 at 8:11 PM, rShetty wrote: > > Suggest the most efficient Data Structures and algorithms to implement > > Undo an

[algogeeks] Re: Cisco Question

2011-06-27 Thread rShetty
@Dave Thank You very much :) On Jun 27, 8:48 pm, piyush kapoor wrote: > thanks a lot for the wonderful explanation :-) > > > > > > > > > > On Mon, Jun 27, 2011 at 7:17 PM, Dave wrote: > > @Rajeev and Piyush: Numbering the bits from the right starting with 0 > > as usual, you see that you need to

Re: [algogeeks] Reverse

2011-06-27 Thread vaibhav shukla
h.yup On Mon, Jun 27, 2011 at 10:18 PM, vaibhav agarwal < vibhu.bitspil...@gmail.com> wrote: > @vaibhav just like u swap two int variable without using 3rd > > On Mon, Jun 27, 2011 at 10:17 PM, vaibhav shukla > wrote: > >> and how will swap without using temp variable ? >> >> >> On Mon,

Re: [algogeeks] Reverse

2011-06-27 Thread vaibhav agarwal
@vaibhav just like u swap two int variable without using 3rd On Mon, Jun 27, 2011 at 10:17 PM, vaibhav shukla wrote: > and how will swap without using temp variable ? > > > On Mon, Jun 27, 2011 at 10:07 PM, Vishal Thanki wrote: > >> and yes, "s" will be stored in stack everytime you call the func

Re: [algogeeks] Reverse

2011-06-27 Thread vaibhav shukla
and how will swap without using temp variable ? On Mon, Jun 27, 2011 at 10:07 PM, Vishal Thanki wrote: > and yes, "s" will be stored in stack everytime you call the function, > so its a temp variable.. > > string reverse is a simple logic, just iterate i through 1 to n/2 and > swap the i to n-i >

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread vaibhav agarwal
consider G as 1, B as 0 so actually its series of 1 and 0's now consider any sequence GBGBBGGGBG will be represented as 1010011101 objective is to push all 1's at the right end. all '10' pairs need to be swapped at the same time. considering this take for ex 101 the number of swaps is equal to th

Re: [algogeeks] Reverse

2011-06-27 Thread Vishal Thanki
and yes, "s" will be stored in stack everytime you call the function, so its a temp variable.. string reverse is a simple logic, just iterate i through 1 to n/2 and swap the i to n-i On Mon, Jun 27, 2011 at 10:06 PM, Vishal Thanki wrote: > this code will only print, it will not store the reverse

Re: [algogeeks] Reverse

2011-06-27 Thread Vishal Thanki
this code will only print, it will not store the reverse string. On Mon, Jun 27, 2011 at 9:53 PM, Kamakshii Aggarwal wrote: > #include > #include > void revers(char *s) > { >      if(*s) >      { >                     revers(++s); >                     s--; >                     printf("%c ",*s

Re: [algogeeks] Reverse

2011-06-27 Thread Kamakshii Aggarwal
#include #include void revers(char *s) { if(*s) { revers(++s); s--; printf("%c ",*s); } } int main(int argc, char *argv[]) { char arr[]="string"; revers(arr); system("PAUSE"); return 0; } will s be counted

[algogeeks] Re: Nagarro Question

2011-06-27 Thread Sanket
@Juver - I am getting Access denied for the pdf link you sent :( On Jun 27, 8:48 am, "juver++" wrote: > Here it is:http://arxiv.org/PS_cache/arxiv/pdf/0805/0805.1598v1.pdf > > On Jun 27, 5:02 am, Ankit Sablok > wrote: > > > Need a Better Algorithm > > > here is a trivial question we are given an

[algogeeks] Re: OS

2011-06-27 Thread Sanket
@Mihir - Yea, I missed the semi-colon, got it now :-) On Jun 27, 2:00 am, Mihir wrote: > @Sanket: You are wrong. Check the loops again! -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegro

Re: [algogeeks] Re: Statement Riddle

2011-06-27 Thread Vishal Thanki
this may be a reverse race, who comes last will win.. On Mon, Jun 27, 2011 at 6:22 PM, Dave wrote: > Force indain driver finishes second in race. Ferari was next to last. > > Dave > > > > On Jun 27, 2:18 am, Lavesh Rawat wrote: >> *Statement Riddle  - 27 june >>  * >> * >> * >> ** >> *'Ferari d

[algogeeks] Re: Finding a number from 300million list with constraint on memory.

2011-06-27 Thread Sanket
That is true Dave. Since the numbers are random, we could very well have that scenario. To reduce this possibility, we can reverse the allocation - 1.5MB for the array and 500KB for the input. Since the input is going to be read sequentially, we would need to swap only after exhausting all the numb

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread harshit pahuja
hint is : go for counting ,not for shifting o(n). :P On Mon, Jun 27, 2011 at 9:29 PM, pacific :-) wrote: > Can one of you provide some hints in solving this problem ? > > > On Sat, Jun 25, 2011 at 3:34 PM, kartik sachan wrote: > >> @jitendra that's what i am asking forwhat a

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread vaibhav agarwal
@varun: Thanks... On Mon, Jun 27, 2011 at 9:18 PM, varun pahwa wrote: > suppose k is the sum to be found. > @vaibhav: yes it will stop when crossing is there means (j must be greater > than i).initially sum = a[i] + a[j] (where i = 0 n j = n- 1) n we will > increase i when sum is less than k and

Re: [algogeeks] Re: spoj shlights

2011-06-27 Thread pacific :-)
Can one of you provide some hints in solving this problem ? On Sat, Jun 25, 2011 at 3:34 PM, kartik sachan wrote: > @jitendra that's what i am asking forwhat algo i should > implement to get process in 1 sec? > > -- > You received this message because you are subscribed to the Go

[algogeeks] Re: O(n) Time is the problem. ..

2011-06-27 Thread Sanket
@Dave - Wouldn't your solution also become O(kn) where k = number of bits in the number? In this summation - O(n) + O(n/2) + O(n/4) + ...= O(n) - you would have O(n) appearing 'k' times. Each entry is O(n/ 2^i) where 'i' is the bit position from right to left, starting at 0. The range of 'i' is fro

[algogeeks] Re: MS question

2011-06-27 Thread Sanket
Do we really need to reverse? Can't we apply any normal sorting algo like merge sort or quick sort and for the comparison part of it, use the last characters of each string only? On Jun 27, 4:21 am, varun pahwa wrote: > reverse all strings and then sort. > > On Mon, Jun 27, 2011 at 2:28 PM, Nisha

Re: [algogeeks] Re: Cisco Question

2011-06-27 Thread piyush kapoor
thanks a lot for the wonderful explanation :-) On Mon, Jun 27, 2011 at 7:17 PM, Dave wrote: > @Rajeev and Piyush: Numbering the bits from the right starting with 0 > as usual, you see that you need to move the even-numbered bits one bit > to the left and the odd-numbered bits one bit to the righ

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread varun pahwa
suppose k is the sum to be found. @vaibhav: yes it will stop when crossing is there means (j must be greater than i).initially sum = a[i] + a[j] (where i = 0 n j = n- 1) n we will increase i when sum is less than k and decrease j when sum < k.stop if sum == k. and if no i , j found till j > i. the

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Bharath Soma
@ankit, sorry i was mistaken its O(nlogn) for searching the two elements... On Mon, Jun 27, 2011 at 8:04 PM, Swathi wrote: > Dave, > > Can you provide the psuedo code for this.. > > Thanks, > Swathi > > > On Mon, Jun 27, 2011 at 7:30 PM, Dave wrote: > >> @Sunny. Mea culpa. You are correct. Revi

[algogeeks] Reverse

2011-06-27 Thread rShetty
Reversing a String without using a temporary variable ? Rajeev N B -- 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+uns

[algogeeks] URGENT Requirerment for C#.NET Developer in Columbus, OH 6+ Months

2011-06-27 Thread Aakif - Gain America, Inc.
Hello, We have a hot opening for... Job Title: C#.NET Developer Location: Columbus, OH Duration: 6+ Months Must be onsite interview. Job Profile: These resources will be developing multiple applications. Experience with C#, .NET, Agile, TFS and Java Scripts is a must.

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Swathi
Dave, Can you provide the psuedo code for this.. Thanks, Swathi On Mon, Jun 27, 2011 at 7:30 PM, Dave wrote: > @Sunny. Mea culpa. You are correct. Revised (and correct) algorithm. > Do two inorder traversals, one in the usual (descend to the left > before descendung to the right) direction and

Re: [algogeeks] Anyone have "The google resume book"

2011-06-27 Thread Swathi
This book http://www.amazon.com/gp/product/0470927623/ref=as_li_ss_tl?ie=UTF8&tag=care01-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0470927623 Thanks, swathi On Mon, Jun 27, 2011 at 6:50 PM, Vivek Srivastava < srivastava.vivek1...@gmail.com> wrote: > Hi swathi, > > What do you mean

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread juver++
Yes, now it is fine enough :) -- 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/-/8z1hcl2hQskJ. To post to this group, send email to algogeeks@googlegroups.com.

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Dave
@Sunny. Mea culpa. You are correct. Revised (and correct) algorithm. Do two inorder traversals, one in the usual (descend to the left before descendung to the right) direction and the other in the reversed(descend to the right before descending to the left) direction. Let u and r be the current nod

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread juver++
It doesn't work. In your idea values of nodes represented by u and v always increased, cause you are doing inorder traversal. -- 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

[algogeeks] Re: Nagarro Question

2011-06-27 Thread juver++
Here it is: http://arxiv.org/PS_cache/arxiv/pdf/0805/0805.1598v1.pdf On Jun 27, 5:02 am, Ankit Sablok wrote: > Need a Better Algorithm > > here is a trivial question we are given an array of 2n elements in the > form > {a1,a2,a3,..,an,b1,b2,b3b...bn} > > we need to output a resultiing arr

[algogeeks] Re: Cisco Question

2011-06-27 Thread Dave
@Rajeev and Piyush: Numbering the bits from the right starting with 0 as usual, you see that you need to move the even-numbered bits one bit to the left and the odd-numbered bits one bit to the right. You could do this one bit-pair at a time, but it would be more efficient if you could do all pairs

Re: [algogeeks] Anyone have "The google resume book"

2011-06-27 Thread Vivek Srivastava
Hi swathi, What do you mean exactly by the google resume book? On Sun, Jun 26, 2011 at 10:50 PM, Swathi wrote: > > -- > 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 u

Re: [algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread vaibhav agarwal
@varun: where does the algo stops? when the two pointer crosses over or both of them reaches other opposite end. On Mon, Jun 27, 2011 at 3:04 PM, Piyush Sinha wrote: > Instead of using an array...we can do this by converting the BST into a > doubly linked list...but this will definitely

Re: [algogeeks] Re: Cisco Question

2011-06-27 Thread piyush kapoor
Yep,I also want to know the same.. On Mon, Jun 27, 2011 at 6:23 PM, rajeev bharshetty wrote: > @ Dave How to think about the answer to the above question . I mean How do > I tackle such problems ? > > > On Mon, Jun 27, 2011 at 6:17 PM, Dave wrote: > >> y = ((x & 0x55) << 1) | ((x >> 1) & 0x55).

Re: [algogeeks] Re: Cisco Question

2011-06-27 Thread rajeev bharshetty
@ Dave How to think about the answer to the above question . I mean How do I tackle such problems ? On Mon, Jun 27, 2011 at 6:17 PM, Dave wrote: > y = ((x & 0x55) << 1) | ((x >> 1) & 0x55). > > Note, 0x55 = 01010101 in binary. > > Dave > > On Jun 27, 7:18 am, rShetty wrote: > > Given a byte, wr

Re: [algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread sunny agrawal
@Dave i think your solution won't work consider inorder traversal of a BST is 1 6 7 8 15 and x = 14 initially both u,v (1,1) according to u your algorithm will proceed like (1,1) -> (1,6) -> (1,7) -> (1,8) -> (1,15) -> (6,15) -> (15,15) and clearly in second step of your solution if (

[algogeeks] Re: Statement Riddle

2011-06-27 Thread Dave
Force indain driver finishes second in race. Ferari was next to last. Dave On Jun 27, 2:18 am, Lavesh Rawat wrote: > *Statement Riddle  - 27 june >  * > * > * > ** > *'Ferari driver' easily beats the 'force indain driver' in a two care > race.How did Indian newspapers * > *truthfully report so

[algogeeks] Re: Cisco Question

2011-06-27 Thread Dave
y = ((x & 0x55) << 1) | ((x >> 1) & 0x55). Note, 0x55 = 01010101 in binary. Dave On Jun 27, 7:18 am, rShetty wrote: > Given a byte, write a code to swap every two bits. [Using bit > operators] > >  Eg: Input: 10 01 11 01 Output: 01 10 11 10 -- You received this message because you are subscri

[algogeeks] Re: given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Dave
@Nishant: No need to store the data in an array. Do two inorder traversals simultaneously. Let u and v be the current nodes of the two traversals, respectively. If u + v < x, then advance the "v" traversal. If u + v > x, advance the "u" traversal. Dave On Jun 27, 3:40 am, Nishant Mittal wrote: >

Re: [algogeeks] Re: O(n) Time is the problem. ..

2011-06-27 Thread Bhavesh agrawal
can anyone plz post the code for this problem -- 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+unsubscr...@googlegroups.c

[algogeeks] Cisco Question

2011-06-27 Thread rShetty
Given a byte, write a code to swap every two bits. [Using bit operators] Eg: Input: 10 01 11 01 Output: 01 10 11 10 -- 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 unsubscr

Re: [algogeeks] [brain teaser ] Statement Riddle

2011-06-27 Thread sharad kumar
i have added anton nomiste as the new moderator... On Mon, Jun 27, 2011 at 5:36 PM, sharad kumar wrote: > banned!!! > > On Mon, Jun 27, 2011 at 5:32 PM, shady wrote: > >> if moderators are alive, can they ban him ? >> >> >> On Mon, Jun 27, 2011 at 12:48 PM, Lavesh Rawat wrote: >> >>> *Statement

Re: [algogeeks] [brain teaser ] Statement Riddle

2011-06-27 Thread Shachindra A C
+1 to shady's post. Please ban him. On Mon, Jun 27, 2011 at 5:32 PM, shady wrote: > if moderators are alive, can they ban him ? > > > On Mon, Jun 27, 2011 at 12:48 PM, Lavesh Rawat wrote: > >> *Statement Riddle - 27 june >> * >> * >> * >> ** >> *'Ferari driver' easily beats the 'force indain d

Re: [algogeeks] [brain teaser ] Statement Riddle

2011-06-27 Thread shady
if moderators are alive, can they ban him ? On Mon, Jun 27, 2011 at 12:48 PM, Lavesh Rawat wrote: > *Statement Riddle - 27 june > * > * > * > ** > *'Ferari driver' easily beats the 'force indain driver' in a two care > race.How did Indian newspapers * > *truthfully report so to look as 'force i

[algogeeks] [brain teaser ] Statement Riddle

2011-06-27 Thread Lavesh Rawat
*Statement Riddle - 27 june * * * ** *'Ferari driver' easily beats the 'force indain driver' in a two care race.How did Indian newspapers * *truthfully report so to look as 'force indain drive' had outdone the 'ferari driver' Think ?? * *Update Your Answers at* : Click Here

Re: [algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Piyush Sinha
Instead of using an array...we can do this by converting the BST into a doubly linked list...but this will definitely modify the BST.. On Mon, Jun 27, 2011 at 3:01 PM, varun pahwa wrote: > @ankit: no need to use hash table for that. > simply run two pointers one from 0 and second from n - 1. > >

Re: [algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread varun pahwa
@ankit: no need to use hash table for that. simply run two pointers one from 0 and second from n - 1. On Mon, Jun 27, 2011 at 2:51 PM, ankit sambyal wrote: > @Bharath : Cud u plz explain how r u searching the elements in O(n) time? > Because if we use binary search, it will have O(n*log n ) wors

Re: [algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Nishant Mittal
(for array sorted in ascending order) take 2 indexes i and j pointing to 1st and last element of the array respectively... now if(arr[i]+arr[j] == x) print(arr[i]); print(arr[j]; else if(arr[i]+arr[j]>x) j--; else i++; I think this should work...(i've not checked) correct me if i m wrong On 6/27

Re: [algogeeks] MS question

2011-06-27 Thread varun pahwa
reverse all strings and then sort. On Mon, Jun 27, 2011 at 2:28 PM, Nishant Mittal wrote: > WAP to sort an array of character strings on the basis of last > character of each string > eg:- {xxxc , yyya, zzzb} => {yyya , zzzb, xxxc} > > -- > You received this message because you are subscribed to

  1   2   >