Re: [algogeeks] Re: TRIE problem

2012-02-17 Thread rajul jain
I think you should use TST data structure for this problem. You can find some implementation HERE On Thu, Feb 16, 2012 at 11:32 AM, pavan wrote: > i am getting WA by implementing TRIE .can anyone help me with the test > cases for which the following code is failing. > > #i

Re: [algogeeks] Bit Magic ....Always Stuck ..

2011-10-16 Thread rajul jain
I have read this question earlier the algo is like this 1)Traverse from right to left , once we passed 1, turn on next 0 and also turn off the one that's just to right side of that. example xxx11011 become xx101011 2) for making number small just rearrange all 1's to be as right as possible. xx101

Re: [algogeeks] what is the use of fflush ?

2011-10-09 Thread rajul jain
just take input a and b in one statement like this scanf("%d %d ",&a ,&b); On Sun, Oct 9, 2011 at 4:50 PM, Saravanan Selvamani < saravananselvam...@gmail.com> wrote: > Hi, > In the following programming when i gave character input rather > than integer , the following scanf statement is

Re: [algogeeks] Sapient Help!!

2011-10-03 Thread rajul jain
Hi akanksha Thanks for your information .Today i have cleared my written, can you please share some information about both interview process specifically that attribute round what sort of question they asked in that interview. Rajul On Fri, Sep 30, 2011 at 5:35 PM, Akanksha . wrote: > I m a 20

Re: [algogeeks] Mentor Graphics Help !!

2011-09-14 Thread rajul jain
If anybody know about placement procedure of mentor graphics pls help On Mon, Aug 22, 2011 at 11:09 PM, Ankur Garg wrote: > Also to add, > > If you post profile in their portal no reply comes...How to apply ...can > any one here refer my candidature for Mentor Graphics ..I have 2 yrs work ex > w

Re: [algogeeks] Re: Indus Valley Recruitment

2011-09-05 Thread rajul jain
only logical reasoning and verbal reasoning and LRDI question pattern is not of cat type. they are just calculation type. If you have good calculation you can crack it easily.they also allowed calculator. On Mon, Sep 5, 2011 at 8:16 PM, NITISH SHARMA wrote: > What all comes in the written test??

Re: [algogeeks] Re: Indus Valley Recruitment

2011-09-05 Thread rajul jain
paper was totally calculation based , dont forget to bring your calculator in exam. On Mon, Sep 5, 2011 at 8:10 PM, NITISH SHARMA wrote: > Its coming on 8th n eligibility is 80% aggregate in btech > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Gee

Re: [algogeeks] explain the output..!!

2011-09-05 Thread rajul jain
good question yaar ,from which book you read this. On Mon, Sep 5, 2011 at 7:59 PM, Sanjay Rajpal wrote: > Fourth number is not octal. > > > Sanju > :) > > > > On Mon, Sep 5, 2011 at 7:28 AM, Mohit Goel wrote: > >> got it ..!! thnks everyone >> >> -- >> You received this message because you a

Re: [algogeeks] Re: character count in array

2011-09-03 Thread rajul jain
@ankuj just want to clarify that in hashing method we require array of fixed size let say arr[26] , so is it considered as constant space or not? On Sat, Sep 3, 2011 at 8:02 PM, siddharam suresh wrote: > sol already posted please search old thread > Thank you, > Sid. > > > > On Sat, Sep 3, 2011

Re: [algogeeks] character count in array

2011-09-03 Thread rajul jain
use hashing but you dont get space O(1) in hashing On Sat, Sep 3, 2011 at 6:54 PM, Aman Kumar wrote: > Hiii > if array is given like this > > arr[]=aabcabbcdeadef > > convert this array into like > > arr[]=a4b3c2d2e2f1 > > how can we do this > > can we do it with space complexity O(1). > > reply

Re: [algogeeks] c question

2011-09-03 Thread rajul jain
As declaration of a[100] is defined in main function so main function print 100 , but foo() only know a pointer to a char data type that is why it print 4 in function foo() correct me if i am wrong! On Sat, Sep 3, 2011 at 6:52 PM, UTKARSH SRIVASTAV wrote: > char *p,char [] are both same they b

Re: [algogeeks] c question

2011-09-03 Thread rajul jain
foo(char *s){ printf("%d", sizeof(s)); // correction } in this function foo s is a pointer so it print size of pointer which is 4 . On Sat, Sep 3, 2011 at 6:22 PM, priya ramesh wrote: > In any C program, > int main(){ > char a[100]; > foo(a); > printf("%d", sizeof(a)); > } > foo(char *s){ > p

Re: [algogeeks] Re: Closest ancestor of two nodes

2011-09-02 Thread rajul jain
@anika this solution only works for BST On Mon, Aug 15, 2011 at 4:20 PM, Anika Jain wrote: > node *common_ancestor(node *root, node **prev, int x,int y) > { > if(root->a==x || root->a==y) > return *prev; > else if(root->a > x && root->a > y) > { >

Re: [algogeeks] Find the Max from each sub-array of size k

2011-09-02 Thread rajul jain
I think Dave has already given a good solution in earlier post. first make a max heap of first k elements and then print max value which is root . now add next element in heap and again print max value follow this procedure till you reach end of an array. On Fri, Sep 2, 2011 at 9:04 AM, Anup Gha

Re: [algogeeks] Find Max Sum Value Pairs

2011-09-01 Thread rajul jain
@bharat I think pair of your example would be (4,4) , (4,3) ,(3,4), (3,3) correct me if am wrong.. On Thu, Sep 1, 2011 at 4:55 PM, bharatkumar bagana < bagana.bharatku...@gmail.com> wrote: > @Mac: It gives us the first largest pair but need not all n pairs .. > ex: > A=1 1 3 4 > B=1 2 3 4 >

Re: [algogeeks] C-Question

2011-08-20 Thread rajul jain
5.375 in normalised form is - 0100 1010 1100 As we type cast into char so in little endian system it take 8 bits from last and store into p[0] , then it take next 8 bits store it into p[1] so on ... In printf statement here X is specifier for float so it print hexadecimal

Re: [algogeeks] Re: an amazing amazon question!

2011-08-17 Thread rajul jain
but its speed is uniform i think Don answer is right On Wed, Aug 17, 2011 at 11:42 PM, Douglas Diniz wrote: > There are infinite solutions with this logic, because the third > milestone can have more than 2 digits. > > On Wed, Aug 17, 2011 at 3:08 PM, sagar pareek > wrote: > > @rajul > > > > 61

Re: [algogeeks] Re: an amazing amazon question!

2011-08-17 Thread rajul jain
thnx for correcting me On Wed, Aug 17, 2011 at 11:38 PM, sagar pareek wrote: > @rajul > > 61-16 =45 > > its not 55 miles per hour > > > On Wed, Aug 17, 2011 at 11:33 PM, Don wrote: > >> Actually you are all wrong. His uniform speed was zero, and he was >> sitting by milestone 44 the whole time.

Re: [algogeeks] an amazing amazon question!

2011-08-17 Thread rajul jain
what abou 16 , 61 , 116 so avg 55 m/hr On Wed, Aug 17, 2011 at 10:35 PM, sagar pareek wrote: > 16, 61, 106 average speed is 45 miles/hour > > > On Wed, Aug 17, 2011 at 10:28 PM, priya ramesh < > love.for.programm...@gmail.com> wrote: > >> A car is traveling at a uniform speed.The driver sees a m

Re: [algogeeks] How to hash Strings

2011-08-14 Thread rajul jain
what about anagram On Sun, Aug 14, 2011 at 10:32 PM, Gaurav Menghani wrote: > The easiest one is to take the sum of their ASCII values. > > On Sun, Aug 14, 2011 at 12:36 PM, rohit wrote: > > I came accross a problem where i need to hash strings.. > > What is the best way to hash strings?? > > >

Re: [algogeeks] Re: TRee question...

2011-08-13 Thread rajul jain
see WgpShashank second point carefully it say successor is parent of left node so solution of you BST is parent of 2 which is 4 On Sat, Aug 13, 2011 at 7:50 PM, Anika Jain wrote: > @ashmantak: the figure of dipankar is incorrect but his point is correct.. > for a tree like > >

Re: [algogeeks] iocl recruitment process

2011-08-12 Thread rajul jain
If you are in top 5 in your coe branch then dont take stress and if not then dont worry about process bcoz they take only 2-3 student from top 5 each year in GEN category . On Fri, Aug 12, 2011 at 12:34 PM, coder coder wrote: > iocl is coming to my college > please any dceite please tell what the

Re: [algogeeks] an array question

2011-08-12 Thread rajul jain
I have use bactracking http://codepad.org/rF4Sr3zk it works for only 1 and 2digit number On Fri, Aug 12, 2011 at 6:04 PM, Yasir Imteyaz wrote: > An array of integers is given and you have to find the largest possible > integer by concatenating all elements: > > example: > array: 87 36 52

Re: [algogeeks] Re: what is complexity of func(p)

2011-08-09 Thread rajul jain
thanks to all On Tue, Aug 9, 2011 at 8:45 PM, shady wrote: > he is questioning the complexity and not the algorithm... btw, you are > right > > > On Tue, Aug 9, 2011 at 8:41 PM, Don wrote: > >> I don't think that this function is doing what you want it to do. If >> you ask for a^b, it returns a

Re: [algogeeks] amazon question

2011-08-08 Thread rajul jain
How many Children process following program produce * void main() { int p1= fork(); if (p1 == 0) { int p2 = fork(); if (p2 != 0) { fork(); } } } * On Mon, Aug 8, 2011 at 11:11 AM, Kamakshii Aggarwal wrote: >

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
gt; >> check this condition >> if( node->left == NULL && node->right == NULL ) >> it is true only for leaves node >> >> On Mon, Aug 8, 2011 at 10:46 PM, rajul jain >> wrote: >> > I have also made same answer on first look but read 3rd option

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
) > it is true only for leaves node > > On Mon, Aug 8, 2011 at 10:46 PM, rajul jain > wrote: > > I have also made same answer on first look but read 3rd option correctly > it > > say deletion of leaves from right to left not internal nodes. > > > > On Mon,

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
I have also made same answer on first look but read 3rd option correctly it say deletion of leaves from right to left not internal nodes. On Mon, Aug 8, 2011 at 10:36 PM, Debabrata Das < debabrata.barunhal...@gmail.com> wrote: > i think 3 > > On Mon, Aug 8, 2011 at 10:32 PM, raju

Re: [algogeeks] amazon test question!!!

2011-08-08 Thread rajul jain
got it thanks On Mon, Aug 8, 2011 at 10:30 PM, Akash Mukherjee wrote: > i think its 1 though ... > > > On Mon, Aug 8, 2011 at 10:21 PM, rohit wrote: > >> What will the following code snippet do, when is it passed the root of >> a binary tree ? >> func( Node *node){ >> >> if(node->right !=

Re: [algogeeks] Directi Question

2011-08-07 Thread rajul jain
let expected time is T , if we get even(probability 1/2) on first throw so T become 1 If dont then you are at same place where you started so T = (1/2) (1) + (1/2) ( 1+T) => T =2 On Sun, Aug 7, 2011 at 6:05 PM, rajul jain wrote: > If we get even number (probability 1/2) in first thro

Re: [algogeeks] Directi Question

2011-08-07 Thread rajul jain
If we get even number (probability 1/2) in first throw , so the expected run is 1 If first throw give ODD (probability 1/2) ,the run needed become 1 + run needed until second odd number .This last waiting time is 2 . Thus expected run become (1/2) (1) + (1/2)(1+2) = 2 On Sat, Aug 6, 2011 at 8:04

Re: [algogeeks] Re: Duplicates in a string

2011-08-05 Thread rajul jain
Can You please explain this bit manipualtion On Fri, Aug 5, 2011 at 10:31 PM, hary rathor wrote: > #include > int main () > { > char str[]="hello world"; > int i,j=0,checker=0; > > for(i=0;i { > int val=str[i]-'a'; >if ((checker&(1checker|=(1< } > > str[j]='\0

Re: [algogeeks] Re: Sequence Puzzle 13april

2011-04-19 Thread rajul jain
this is look and say sequence next term is 312211 13112221 On Tue, Apr 19, 2011 at 7:43 AM, nagajyothi gunti < nagajyothi.gu...@gmail.com> wrote: > Is the answer as follows: > > *1 1* > *2 1* > 1 2 *1 1* > 1 1 1 2* 2 1* > 1 1 2 1 1 1 *1 1* > 1 1 2 1 1 1 2 1 *2 1* > > > On Thu, Apr 14, 2011 at 2:3

Re: [algogeeks] Sort array with two subparts sorted

2011-04-12 Thread rajul jain
use merge sort On Tue, Apr 12, 2011 at 3:07 PM, Akash Agrawal wrote: > Given an array with two subparts sorted. How will you make a final sorted > array. > > i/p: 1, 5, 7, 9, 11, 23, 2, 3, 8, 9, 21 > > o/p: > 1, 2, 3, 5, 7, 8, 9, 9, 11, 21, 23 > > > Regards, > Akash Agrawal > http://tech-queries

Re: [algogeeks] brain teaser

2011-03-05 Thread rajul jain
thankx terence and tushar On Thu, Mar 3, 2011 at 3:18 PM, Terence wrote: > All but the last person could get free. > The last person tells the parity of number of RED(or BLACK) hat before > him.(and pray God's forgiveness :<) > Then the rest can tell the color of his own hat using what he sees b

Re: [algogeeks] Re: brain teaser

2011-03-04 Thread rajul jain
"even", "odd", ... etc. When it's your turn, if the black hats you see match the running parity, you're Red; Black otherwise. Call out your color. On Fri, Mar 4, 2011 at 7:51 PM, rajul jain wrote: > > they only hear the answer given by prisoner >

Re: [algogeeks] Re: brain teaser

2011-03-04 Thread rajul jain
they only hear the answer given by prisoner On Fri, Mar 4, 2011 at 6:43 PM, rajul jain wrote: > they can see persons in front of them. > > > On Fri, Mar 4, 2011 at 6:42 PM, rajul jain wrote: > >> @vipin if thay can hear then then what would be the purpose of this >> q

Re: [algogeeks] Re: brain teaser

2011-03-04 Thread rajul jain
they can see persons in front of them. On Fri, Mar 4, 2011 at 6:42 PM, rajul jain wrote: > @vipin if thay can hear then then what would be the purpose of this > question > then last person just sacrifice himself and just tell the color of hat of > person standing in front of him

Re: [algogeeks] Re: brain teaser

2011-03-04 Thread rajul jain
@vipin if thay can hear then then what would be the purpose of this question then last person just sacrifice himself and just tell the color of hat of person standing in front of him dont give this type of comments keep in mind "No communication" rule in this question On Fri, Mar 4, 2011 at 5:53 P

Re: [algogeeks] Re: brain teaser

2011-03-03 Thread rajul jain
but they cannot communicate with each other (neither talking not hearing) they just see person stand in front of him. On Thu, Mar 3, 2011 at 11:04 PM, Dave wrote: > I have a way to save 19. Let each prisoner have his own private > variable C, which he initializes to RED if he sees an odd number

Re: [algogeeks] Re: brain teaser

2011-03-03 Thread rajul jain
@param But how can u prove that. On Thu, Mar 3, 2011 at 5:16 PM, Param10k wrote: > At d Max 1 person 'll die > > > -Param > http://teknotron-param.blogspot.com/ > > On Mar 3, 3:20 pm, rajul jain wrote: > > @naveen you are right there is a variant similar to t

Re: [algogeeks] Amazon Question

2011-03-03 Thread rajul jain
@ankit they both(gunjan & nishanth) are right in term of complexity but their solution is not correct ... tell me if i am wrong On Thu, Mar 3, 2011 at 8:15 PM, Ankit Sinha wrote: > @Gunjan & Nishanth, yes, you both are right. I just missed the basics > in dividing it in n/2 logically for each c

Re: [algogeeks] Amazon Question

2011-03-03 Thread rajul jain
i think he is wrong bcoz this array in not sorted one. so solution of Ankit is right. On Thu, Mar 3, 2011 at 7:33 PM, nishaanth wrote: > Ignore the previous post..there is a small error in the code.. > @Ankit..your algm is O(n)...you should split the problem size to n/2 at > every stage...rather

Re: [algogeeks] brain teaser

2011-03-03 Thread rajul jain
Thu, Mar 3, 2011 at 3:32 PM, rajul jain wrote: > >> @naveen >> but in this question don't know numbers of black and red hats like prison >> and hat puzzle >> >> >> On Thu, Mar 3, 2011 at 3:25 PM, Naveen Kumar >> wrote: >> >>> http:/

Re: [algogeeks] brain teaser

2011-03-03 Thread rajul jain
@naveen but in this question don't know numbers of black and red hats like prison and hat puzzle On Thu, Mar 3, 2011 at 3:25 PM, Naveen Kumar wrote: > http://en.wikipedia.org/wiki/Prisoners_and_hats_puzzle > > On Thu, Mar 3, 2011 at 3:01 PM, amit kumar wrote: > >> ya at least 10 can be easily fre

Re: [algogeeks] [brain teaser ] 3march

2011-03-03 Thread rajul jain
2500 gold 5 pirates Set the initial 2 pirates gold equal as follows: x = total gold 100 + [(x-100)/6] = 200 + [(x - 200 - 100 - ((x-100)/6)/6] Rearranging and solving: x - 100 = 300 + x - [(x-100)/6] And again: 0 = 400 - [(x-100)/6] And again: 0 = 2400 - x + 100 Therefore x = 2500 Substitue