Re: [algogeeks] Thoughtworks Coding Qn on Aug-8 2011

2011-08-09 Thread Reynald Suz
Please note: - Your OO design counts more marks, so, try to make use of well-known design principles - Your code should all easy modification. Eg: Dont use IF-ELSE. - Change management and feature extension in your code should be flexible. In, Coding round you will be paired with

Re: [algogeeks] Doubts

2011-08-09 Thread aditi garg
@aditya and dipankar: the ans given ws 500ns that is why i posted dis ques...i ws getting the same ans... On Tue, Aug 9, 2011 at 9:45 AM, ankit sambyal ankitsamb...@gmail.comwrote: @aditya : can u explain how u got c part as the answer for question 2 -- You received this message because you

[algogeeks] probability!-need help

2011-08-09 Thread programming love
Please send a link where i can find hard permutations and combinations and probability questions. Please help. If you guys have good e books or materials for apti questions, please mail me. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] output help

2011-08-09 Thread Rohit Srivastava
#includestdio.h #includeconio.h int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit={1,2,2}; printf(%d %d %d\n,bit.bit1,bit.bit3,bit.bit4); getche(); return 0; } the above code gives output : -1 2 2 any idea why??? -- You

Re: [algogeeks] output help

2011-08-09 Thread aditi garg
I think it is because bit1 is only 1 bit fwide and whn u initialize it to 1,since MSB is 1 it treats it as a negative integer...Plz correct me if i am wrong... On Tue, Aug 9, 2011 at 12:24 PM, Rohit Srivastava access2ro...@gmail.comwrote: #includestdio.h #includeconio.h int main() {

Re: [algogeeks] mcq

2011-08-09 Thread Kamakshii Aggarwal
please explain On Tue, Aug 9, 2011 at 9:07 AM, Dipankar Patro dip10c...@gmail.com wrote: ans : n + 2nk - k^2 - k On 9 August 2011 08:43, Raman raman.u...@gmail.com wrote: Yes, the answer is n + 2nk - k^2 -k -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] output help

2011-08-09 Thread sanjay ahuja
Int bit3:4 will be read as lower order 4 bits of bit3 and this will be treated as int (signed). Thus lower order bit of bit3 which is 2, are 0010 which is 2 try with 1) int bit3:2, output will be -2 2) unsigned int bit3:2, output will be 2. I hope it is cleared now On 8/9/11, Rohit Srivastava

Re: [algogeeks] output help

2011-08-09 Thread Rohit Srivastava
hey guys thanks got it!! On Tue, Aug 9, 2011 at 12:49 PM, sanjay ahuja sanjayahuja.i...@gmail.comwrote: Int bit3:4 will be read as lower order 4 bits of bit3 and this will be treated as int (signed). Thus lower order bit of bit3 which is 2, are 0010 which is 2 try with 1) int bit3:2,

[algogeeks] DBMS

2011-08-09 Thread krishna meena
In an RDBMS with m attributes, how many superkeys are possible? -- 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

Re: [algogeeks] output help

2011-08-09 Thread dinesh bansal
On a little-endian machine, bit structure will be represented as: 0x00 00 00 45 which is bit.bit4 = 0010 (2 in decimal) bit.bit3 = 0010 (2 in decimal) bit.bit1 = 1 (1 in decimal) since bit.bit1 exists at the rightmost position, while displaying data as integer, compiler just repeats the same

Re: [algogeeks] Re: Probability Puzzle

2011-08-09 Thread Arun Vishwanathan
@dave: yes it seems so that 17/18 is correct...I deduced it from the cond prob formula.. I have a minor doubt in general why prob( 2nd toss is a head given that a head occurred in the first toss ) doesnt seem same as p( head in first toss and head in second toss with fair coin) +p(head in

Re: [algogeeks] DBMS

2011-08-09 Thread aditi garg
2^m-1...?? Im not sure tho On Tue, Aug 9, 2011 at 1:09 PM, krishna meena krishna.meena...@gmail.comwrote: In an RDBMS with m attributes, how many superkeys are possible? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Re: Paypal interview Questions

2011-08-09 Thread Arun Vishwanathan
@saurabh: are u referring to bit map sort? On Mon, Aug 8, 2011 at 5:51 PM, saurabh singh saurab...@gmail.com wrote: If you limit the magnitude of numbers,it is On Mon, Aug 8, 2011 at 9:02 PM, siva viknesh sivavikne...@gmail.comwrote: is there any possible solution for O(1) space and

Re: [algogeeks] Doubts

2011-08-09 Thread Rohit Srivastava
@aditi did they mention any thing about miss penalty also in the question ?? On Tue, Aug 9, 2011 at 11:48 AM, aditi garg aditi.garg.6...@gmail.comwrote: @aditya and dipankar: the ans given ws 500ns that is why i posted dis ques...i ws getting the same ans... On Tue, Aug 9, 2011 at 9:45 AM,

Re: [algogeeks] Doubts

2011-08-09 Thread aditi garg
@Rohit:No...i directly copy pasted the ques...nothing else mentioned...and what if thr ws sm miss penalty?what wud be the change in soution? On Tue, Aug 9, 2011 at 1:37 PM, Rohit Srivastava access2ro...@gmail.comwrote: @aditi did they mention any thing about miss penalty also in the question

Re: [algogeeks] Doubts

2011-08-09 Thread Rohit Srivastava
yup !!! it will increase the avg access time On Tue, Aug 9, 2011 at 1:39 PM, aditi garg aditi.garg.6...@gmail.comwrote: @Rohit:No...i directly copy pasted the ques...nothing else mentioned...and what if thr ws sm miss penalty?what wud be the change in soution? On Tue, Aug 9, 2011 at 1:37

[algogeeks] solve this!

2011-08-09 Thread programming love
*In a crew of 12 members rowing team, 6 members are placed on either side of the boat. 3 men row on the right and 2 men row on the left. Find the number of ways of arranging the crew members on each side.* * * *Give the answer in terms of P and C. Example, 12C5 * 12P5+2P1*2C2 * -- You received

Re: [algogeeks] Re: max product!

2011-08-09 Thread Prakash D
so you should use absolute values in second part On Tue, Aug 9, 2011 at 2:20 AM, Dave dave_and_da...@juno.com wrote: @Prakash: Yeah, but doesn't the max take care of that? Dave On Aug 8, 3:07 pm, Prakash D cegprak...@gmail.com wrote: yeah.. but the smaller numbers must be negative in

Re: [algogeeks] Re: max product!

2011-08-09 Thread Prakash D
yeah, yours is enough :) tried with various combinations.. thanks On Tue, Aug 9, 2011 at 2:20 AM, Dave dave_and_da...@juno.com wrote: @Prakash: Yeah, but doesn't the max take care of that? Dave On Aug 8, 3:07 pm, Prakash D cegprak...@gmail.com wrote: yeah.. but the smaller numbers must be

Re: [algogeeks] solve this!

2011-08-09 Thread Prakash D
12C6* 6c3 * 6C2 On Tue, Aug 9, 2011 at 2:10 PM, programming love love.for.programm...@gmail.com wrote: members -- 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

Re: [algogeeks] Re: directi prepration

2011-08-09 Thread NIKHIL JAIN
can any dce student give an idea whats the procedure and what are the questions asked by directi recruitment group -- 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

Re: [algogeeks] solve this!

2011-08-09 Thread sagar pareek
@prakash it will be 2*12C6*2*6C3*2*6C2 2 each for either side, left and right On Tue, Aug 9, 2011 at 3:00 PM, Prakash D cegprak...@gmail.com wrote: 12C6* 6c3 * 6C2 On Tue, Aug 9, 2011 at 2:10 PM, programming love love.for.programm...@gmail.com wrote: members -- You received this

Re: [algogeeks] solve this!

2011-08-09 Thread sonia.bits
I think it shud be 2*12C6*6C3*6C2 initial 2 is for once we have selected 6 members out of 12, we can either place them on left side or right side. @sagar: Could u please explain why have you used 2 two times more? On Tue, Aug 9, 2011 at 3:51 PM, sagar pareek sagarpar...@gmail.com wrote: @prakash

Re: [algogeeks] Re: directi prepration

2011-08-09 Thread Kunal Yadav
The procedure was like this:- First they had a written test of 45 questions of 90 mins. Depending on the performance in the test they divided selected students into two buckets. one for software dev and other for sys ops. Then there was coding round. For sys ops one has to extract some information

Re: [algogeeks] solve this!

2011-08-09 Thread programming love
left- 12C6*6C2 right- 12C6*6C3 Why is 6C2*6C3 combined in a single expression?? On Tue, Aug 9, 2011 at 4:27 PM, programming love love.for.programm...@gmail.com wrote: Here you are only selecting the crew members. How will you arrange them? -- You received this message because you are

Re: [algogeeks] solve this!

2011-08-09 Thread programming love
got it! @sagar there shudn be 2's anywhere in the expression. The different combinations formed on the left hand side by choosing 6 out of 12 will ensure different combinations of other 6 people on the right. So 2*12C6 is not required. Example: P1,P3,P5,P7,P9, P11 on left will leave P2, P4, P6,

Re: [algogeeks] Re: directi prepration

2011-08-09 Thread NIKHIL JAIN
thnx can you please tell some of the written questions so that i will have an idea what kind of questions are being asked by them -- 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.

[algogeeks] Directi Ques

2011-08-09 Thread Raman
given a large string of characters lets call it Sbig. Then there is a small set of characters lets call it Ssmall. You have to find smallest substring of Sbig which contains all characters in Ssmall. For example you are given Sbig = hello what are you doing Ssmall= eo answer is ello -- You

[algogeeks] problem regarding output??

2011-08-09 Thread Rajesh Kumar
why j and k point different location? #includestdio.h main() { int a=10,*j; void *k; j=k=a; k=(int *)k; k++; j++; printf(%u %u\n,j,k); } -- Regards Rajesh Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] solve this!

2011-08-09 Thread sagar pareek
yeah sorry one 2 will be used for either side then auto left and right will be fixed. thanks for correction On Tue, Aug 9, 2011 at 4:39 PM, programming love love.for.programm...@gmail.com wrote: got it! @sagar there shudn be 2's anywhere in the expression. The different combinations

Re: [algogeeks] problem regarding output??

2011-08-09 Thread ankit sambyal
its because void pointer is incremented by 1, when we do k++ whereas integer pointer is incremented by 4, when we do j++ -- 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

Re: [algogeeks] problem regarding output??

2011-08-09 Thread Rajesh Kumar
thanx Ankit On Tue, Aug 9, 2011 at 5:27 PM, ankit sambyal ankitsamb...@gmail.comwrote: its because void pointer is incremented by 1, when we do k++ whereas integer pointer is incremented by 4, when we do j++ -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re: Doubts

2011-08-09 Thread rohit jain
@aditi For the first question. The answer will be ((0.97 *2) + (0.03*2) +(0.03*100)) i.e 5 ns. The reason is that cache is accessed in the case of miss as well, so we need to include that time as well. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] problem regarding output??

2011-08-09 Thread ankit sambyal
The typecasting tells the compiler that the void pointer is now pointing to an integer and when we use this pointer to access the integer it takes value from 4 bytes. But when we try to increment that pointer, it will point to the next byte. Try taking k as pointer to double instead of void, u

Re: [algogeeks] problem regarding output??

2011-08-09 Thread Rohit Srivastava
typecast only temporarily changes the pointer type of LHS but cannot change that of RHS or even LHS permanently On Tue, Aug 9, 2011 at 5:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: The typecasting tells the compiler that the void pointer is now pointing to an integer and when we use this

[algogeeks] Re: Doubts

2011-08-09 Thread rohit jain
In memory heirachy, whenever some data is to be read, first data is to be searched in M1, if the data is found in M1 then system returns the value from there and counted as a hit. If the value is not found in M1 i.e. Miss for M1 then it accesses M2 and returns the value from there. Since nothing

Re: [algogeeks] Re: Doubts

2011-08-09 Thread Rohit Srivastava
@aditi since in the hierarchy m1 comes first so if it is a hit then we dont need to check m2 but in case of a miss 0.03*2 seconds are wasted while searching in m1 then that value is looked for in m2 so i suppose the best answer is given by rohit jain. unless there is some missing data On Tue, Aug

Re: [algogeeks] Re: Doubts

2011-08-09 Thread aditi garg
@Rohit and Rohit : Thnk u so much:) On Tue, Aug 9, 2011 at 5:50 PM, Rohit Srivastava access2ro...@gmail.comwrote: @aditi since in the hierarchy m1 comes first so if it is a hit then we dont need to check m2 but in case of a miss 0.03*2 seconds are wasted while searching in m1 then that value

[algogeeks] Re: Normalised !!

2011-08-09 Thread Abhishek Gupta
binary values are stored in reverse order of byte by byte. in your case, bytes will be stored as, 10101100 0100 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] need a pgm pls help me

2011-08-09 Thread Divya Elangovan
pls help me..its very urgent need a program to divide a file into equal parts(segments) -- * ** * * ****DIVI* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: directi prepration

2011-08-09 Thread aditi garg
@Kunal: in the written test wer the ques technical or aptitude?? On Tue, Aug 9, 2011 at 4:42 PM, NIKHIL JAIN nikhil.jain.shali...@gmail.comwrote: thnx can you please tell some of the written questions so that i will have an idea what kind of questions are being asked by them -- You

Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me

2011-08-09 Thread Srinivas Varanasi
Can any one explain question number 8? On Tue, Aug 9, 2011 at 12:19 PM, Akash Mukherjee akash...@gmail.com wrote: @prashant devcpp gives an error cannot convert `char (*)[5]' to `char*' in initialization ne ideas?? On Mon, Aug 8, 2011 at 12:58 PM, Prashant Kulkarni

Re: [algogeeks] Re: max product!

2011-08-09 Thread WgpShashank
@wastrel sorry for delay as i was busy some other stuffs!! , i think i have handled the case for -ive number as well , just try out for different test cases :) do notify me via mail if anything wrong ? Thanks Shashank Mani Computer Science Birla Institute of Technology,Mesra -- You

Re: [algogeeks] problem regarding output??

2011-08-09 Thread Raman
I read somewhere that arithmetic operations can't be performed to void pointers?? How does v++ does'nt giv error?? -- 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] mcq

2011-08-09 Thread Raman
It's simple arithmetic.. n + 2(n-1) + 2(n-2) +...2(n-k) -- 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/-/nQx_DDDn07QJ. To post to this group, send email to

Re: [algogeeks] MICROSOFT INTERVIEW QUESTIONS faced by my frenz nd me

2011-08-09 Thread Akash Mukherjee
@srinivas if any of the characters (i,n,d,a) appear den it is no longer readso gujr On Tue, Aug 9, 2011 at 6:04 PM, Srinivas Varanasi srinivas4...@gmail.comwrote: Can any one explain question number 8? On Tue, Aug 9, 2011 at 12:19 PM, Akash Mukherjee akash...@gmail.comwrote: @prashant

Re: [algogeeks] Re: directi prepration

2011-08-09 Thread sagar pareek
In written test all the basics like apti(major), OS, networking(major), shell programming(major) were there i m not sure about C programming in written and in coding i too faced that same log ACCESS program...i was unable to fetch system's current time stamp but still my logic was correct so i

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread arpit.gupta
it is (1/5)/( (4/5 *(1/2)^6) + (1/5 * 1)) = 80/85 = 16/17 On Aug 7, 10:54 pm, Nitish Garg nitishgarg1...@gmail.com wrote: Should be (4/5 *(1/2)^6) + (1/5 * 1) = 17/80 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] MS question

2011-08-09 Thread ankit sambyal
Given an array of characters, change the array to something as shown in the following example. Given : ddbbccae O/P : 2d4a2b2c1a1e Do it in the most efficient manner both in terms of time and space ... -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: Probability Puzzle

2011-08-09 Thread shady
go through the posts before posting anything :) On Tue, Aug 9, 2011 at 6:29 PM, arpit.gupta arpitg1...@gmail.com wrote: it is (1/5)/( (4/5 *(1/2)^6) + (1/5 * 1)) = 80/85 = 16/17 On Aug 7, 10:54 pm, Nitish Garg nitishgarg1...@gmail.com wrote: Should be (4/5 *(1/2)^6) + (1/5 * 1) = 17/80 --

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread arpit.gupta
ans is 16/17 + 1/2*1/17 = 33/34 On Aug 7, 10:34 pm, Algo Lover algolear...@gmail.com wrote: A bag contains 5 coins. Four of them are fair and one has heads on both sides. You randomly pulled one coin from the bag and tossed it 5 times, heads turned up all five times. What is the probability

Re: [algogeeks] MS question

2011-08-09 Thread shady
time : O(n) space : O(1) simple bruteforce On Tue, Aug 9, 2011 at 6:29 PM, ankit sambyal ankitsamb...@gmail.comwrote: Given an array of characters, change the array to something as shown in the following example. Given : ddbbccae O/P : 2d4a2b2c1a1e Do it in the most efficient manner

Re: [algogeeks] MS question

2011-08-09 Thread ankit sambyal
@shady : I think there is a catch in that approach. Plz post ur code -- 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

Re: [algogeeks] MS question

2011-08-09 Thread Raghavan
Mapchar,int charCountMap = new HashMap(); for(String char : characters.length){ if(charCountMap.containsKey(char){ charCountMap.get(char)++; }else{ charCountMap.put(char,1); } } later read the map and print the count and key it might suffice. On Tue, Aug 9, 2011 at 6:37 PM, ankit sambyal

Re: [algogeeks] MS question

2011-08-09 Thread ankit sambyal
@raghavan: ur approach uses O(n) space -- 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

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread Dave
@Arpit: No. The probability of getting 6 consecutive heads is 1/5 * 1 + 4/5 * (1/2)^6 ) = 17/80, while the probability of getting 5 consecutive heads is 1/5 * 1 + 4/5 * (1/2)^6 ) = 9/40. Thus, the probability of getting a head on the sixth roll given that you have gotten heads on all five previous

Re: [algogeeks] MS question

2011-08-09 Thread Rohit Srivastava
google on RLE (run length encoding) its almost similar!! On Tue, Aug 9, 2011 at 6:46 PM, ankit sambyal ankitsamb...@gmail.comwrote: @raghavan: ur approach uses O(n) space -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread Dave
@Arun: The probability of getting a head on the first toss is 1/5 * 1 + 4/5 * (1/2) ) = 3/5, while the probability of getting 2 consecutive heads is 1/5 * 1 + 4/5 * (1/2)^2 ) = 2/5. Thus, the probability of getting a head on the second roll given that you have gotten a head on the first roll is

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread arpit.gupta
@dave- calculation mistake on my part - method is right. getting 17/18 only thanks anyways. On Aug 9, 6:26 pm, Dave dave_and_da...@juno.com wrote: @Arun: The probability of getting a head on the first toss is 1/5 * 1 + 4/5 * (1/2) ) = 3/5, while the probability of getting 2 consecutive heads

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread Dave
The probability of getting n consecutive heads is P(n heads) = 1/5 * 1 + 4/5 * (1/2)^n, Thus, the probability of getting a head on the n+1st roll given that you have gotten heads on all n previous rolls is P(n+1 heads | n heads) = P(n+1) / P(n) = ( 1/5 * 1 + 4/5 * (1/2)^(n+1) ) / ( 1/5 * 1 + 4/5 *

Re: [algogeeks] MS question

2011-08-09 Thread siddharam suresh
#includestdio.h #includestring.h #includestdlib.h char * squeez(char *str) { char temp1[100]; char * temp; temp=(char *) malloc(strlen(str)+1); int start=0,cursor=0; char mychar; while(str[start]!='\0') { mychar=str[start]; while(str[start]==str[start+cursor]) cursor ++; if(cursor==1)

[algogeeks] Re: Probability Puzzle

2011-08-09 Thread arpit.gupta
@dave - method is right, calculation mistake on my part, getting 17/18 only. thanks anyways. On Aug 9, 6:26 pm, Dave dave_and_da...@juno.com wrote: @Arun: The probability of getting a head on the first toss is 1/5 * 1 + 4/5 * (1/2) ) = 3/5, while the probability of getting 2 consecutive heads

[algogeeks] Re: problem regarding output??

2011-08-09 Thread UMarius
++ on a void* will increase the address by 1 byte. ++ on a type* will increase the address by sizeof(type) bytes. As if the initial pointer were an array of type On Aug 9, 2:49 pm, Rajesh Kumar testalgori...@gmail.com wrote: why j and k  point different location? #includestdio.h main() {

Re: [algogeeks] MS question

2011-08-09 Thread sagar pareek
Simple ankit #includestdio.h #includestring.h main() { int i,j=0,l,count; char str[100],tmp; printf(Please enter the string\n); fgets(str,100,stdin); l=strlen(str); tmp=str[0]; count=1; for(i=1;il;i++) { if(tmp==str[i]) count++; else { if(count==1) str[j++]=tmp; else{

[algogeeks] Re: texas instruments

2011-08-09 Thread Decipher
I applied to Texas Instruments last year for software profile and these are some of the questions that were asked in interview round : 1) How to find least common ancestor of two nodes in a tree ? 2) Some questions on virtual table and vptr ? Is Vtable created per class or per object ? 3) Some

Re: [algogeeks] MS question

2011-08-09 Thread sagar pareek
my solution is in O(n) time and in O(1) space:D :D On Tue, Aug 9, 2011 at 7:21 PM, sagar pareek sagarpar...@gmail.com wrote: Simple ankit #includestdio.h #includestring.h main() { int i,j=0,l,count; char str[100],tmp; printf(Please enter the string\n);

Re: [algogeeks] MS question

2011-08-09 Thread ankit sambyal
@sagar: for abcd, ur pgm gives abcd. I was trying a pgm which gives 1a1b1c1d. But now i think this problem is wrong, because in this case it exceeds the size of the array if we try to o/p as 1a1b1c1d. Hence we require a new array for it. -- You received this message because you are subscribed to

[algogeeks] c question!

2011-08-09 Thread programming love
*typedef struct {** * *char * a;** * *nodeptr next;** * *}*nodeptr;** * * * *what does nodeptr stand for??* -- 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

Re: [algogeeks] c question!

2011-08-09 Thread rohit jangid
it will give error in line 3 because nodeptr is undefined till that point.. On Aug 9, 2011 8:03 PM, programming love love.for.programm...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] MS question

2011-08-09 Thread saurabh singh
@ankit for abcd the output shud be abcd onlythe whole idea is compressing the string... On Tue, Aug 9, 2011 at 7:52 PM, ankit sambyal ankitsamb...@gmail.comwrote: @sagar: for abcd, ur pgm gives abcd. I was trying a pgm which gives 1a1b1c1d. But now i think this problem is wrong, because

[algogeeks] Amazon question.

2011-08-09 Thread Samba Ganapavarapu
We have an array of integers, we need to find the element a[i],a[j] and a[k] values where.. a[i]^2 + a[k]^2 = a[k] ^2 what would be the fast algorithm to find ? - Samba -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] MS question

2011-08-09 Thread ankit sambyal
ya got it now. I misunderstood the question -- 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.

Re: [algogeeks] c question!

2011-08-09 Thread Rohit Srivastava
yep it will !! any ways nodeptr is another name for pointer to the same structure so you dont need to write structname *nodeptr you can simply write nodeptr *p(say) to declare pointer to the structure On Tue, Aug 9, 2011 at 8:09 PM, rohit jangid rohit.nsi...@gmail.com wrote: it will give error

Re: [algogeeks] Amazon question.

2011-08-09 Thread ankit sambyal
1. Square each element of the array and then sort it---O(nlogn) 2. for(i=0;i(size-3);i++) { j=i+1; k=size-1; while(jk) { if(a[[i] + a[j] == a[k]) printf(\n%d %d %d,sqrt(a[i]),sqrt(a[j]),sqrt(a[k])); else if(a[i] + a[j] a[k]) j++;

[algogeeks] hi

2011-08-09 Thread prashant gautam
hello -- 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 more options, visit this group at

Re: [algogeeks] MS question

2011-08-09 Thread siddharam suresh
saurabh test my program please tell me if any bug is there Thank you, Siddharam On Tue, Aug 9, 2011 at 8:18 PM, saurabh singh saurab...@gmail.com wrote: The code failed for all test cases I tried. On Tue, Aug 9, 2011 at 8:15 PM, ankit sambyal ankitsamb...@gmail.comwrote: ya got it

[algogeeks] Closest ancestor of two nodes

2011-08-09 Thread Raman
Can anyone give me the recursive algo to find closest ancestor of two nodes in a tree(not a BST). -- 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] c question!

2011-08-09 Thread programming love
#includestdio.htypedef struct {char * a; }*nodeptr; main(){nodeptr *h;h-a=programming;printf(hi %s\n, h-a);} this gives an error. Please explain the concept behind this. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Ankuj Gupta
we can do it in logn by using binary search approach found n is the number whose square root has to be if(n==1) return 1; if(n==0) return 0; int low=0,high=n/2,mid,temp; while(1) { mid = (low+high)/2;

Re: [algogeeks] c question!

2011-08-09 Thread Aditya Virmani
is it giving an error at *nodeptr declaration? On Tue, Aug 9, 2011 at 8:26 PM, programming love love.for.programm...@gmail.com wrote: #includestdio.htypedef struct {char * a; }*nodeptr; main(){nodeptr *h;h-a=programming;printf(hi %s\n, h-a);} this gives an error. Please explain the

Re: [algogeeks] c question!

2011-08-09 Thread siddharth srivastava
Hi On 9 August 2011 20:26, programming love love.for.programm...@gmail.comwrote: #includestdio.htypedef struct {char * a; }*nodeptr; main(){nodeptr *h;h-a=programming;printf(hi %s\n, h-a);} this gives an error. Please explain the concept behind this. You have used typedef incorrectly

[algogeeks] Very Important Must Read

2011-08-09 Thread shady
Go through the concept of Information Overload and how to deal with it ? Please make appropriate posts. People posting same answer again and again. Saying hello to others. http://en.wikipedia.org/wiki/Information_overload -- You received this message because you are subscribed to the

Re: [algogeeks] c question!

2011-08-09 Thread Rohit Srivastava
dont use *h just use h On Tue, Aug 9, 2011 at 8:31 PM, siddharth srivastava akssps...@gmail.comwrote: Hi On 9 August 2011 20:26, programming love love.for.programm...@gmail.comwrote: #includestdio.htypedef struct {char * a; }*nodeptr; main(){nodeptr *h;h-a=programming;printf(hi %s\n,

Re: [algogeeks] c question!

2011-08-09 Thread siddharth srivastava
this gives an error. Please explain the concept behind this. try using something like this: #includestdio.h #includemalloc.h typedef struct { char * a; }* nodeptr; main(){ nodeptr h = (nodeptr*)malloc(sizeof(nodeptr*)); h-a=programming; printf(hi %s\n, h-a); } though typedef struct{

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

2011-08-09 Thread Don
I don't think that this function is doing what you want it to do. If you ask for a^b, it returns a^1 in most cases. Try this instead. int power(int a, int b) { int result = 1; if (b == 1) result = a; else if (b1) { result = power(a,b/2); result *= result; if (b%2) result *=

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

2011-08-09 Thread shady
he is questioning the complexity and not the algorithm... btw, you are right On Tue, Aug 9, 2011 at 8:41 PM, Don dondod...@gmail.com 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^1 in most cases. Try this instead. int power(int

Re: Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Dave
@Ankuj: Yeah, but he asked for it to be recursive. Yours is iterative. Dave On Aug 9, 9:56 am, Ankuj Gupta ankuj2...@gmail.com wrote: we can do it in logn by using binary search approach found n is the number whose square root has to be         if(n==1)                 return 1;        

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 sinv...@gmail.com wrote: he is questioning the complexity and not the algorithm... btw, you are right On Tue, Aug 9, 2011 at 8:41 PM, Don dondod...@gmail.com wrote: I don't think that this function is doing what you want it to do. If

Re: [algogeeks] C++ heap vs stack

2011-08-09 Thread siddharth srivastava
On 9 August 2011 10:32, Mohit Goel mohitgoel291...@gmail.com wrote: what the reason behind it how do they differ in functonality..? Here is a good and short expl: http://ee.hawaii.edu/~tep/EE160/Book/chap14/subsection2.1.1.8.html -- You received this message because you are

Re: [algogeeks] c question!

2011-08-09 Thread rohit jangid
a new pointer type that can store the address of such structure for example nodeptr p; will declare a pointer to that struct but it is useless for me. On Aug 9, 2011 8:19 PM, programming love love.for.programm...@gmail.com wrote: @rohith, what if that statement is removed. Now, what will

Re: [algogeeks] MS question

2011-08-09 Thread Dipankar Patro
Here is my code: http://ideone.com/deosU Same as that of Sagar's :D time O(n) and space O(1) On 9 August 2011 20:25, siddharam suresh siddharam@gmail.com wrote: saurabh test my program please tell me if any bug is there Thank you, Siddharam On Tue, Aug 9, 2011 at 8:18 PM, saurabh

Re: [algogeeks] hi

2011-08-09 Thread arvind kumar
hi On Tue, Aug 9, 2011 at 8:24 PM, prashant gautam prashantgautam@gmail.com wrote: hello -- 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

Re: [algogeeks] Re: texas instruments

2011-08-09 Thread aditi garg
for software the technical ppr(frst round) is mcq or subjective? On Tue, Aug 9, 2011 at 7:23 PM, Decipher ankurseth...@gmail.com wrote: I applied to Texas Instruments last year for software profile and these are some of the questions that were asked in interview round : 1) How to find least

Re: Fwd: [algogeeks] Re: recursive nearest square

2011-08-09 Thread Ankuj Gupta
My bad but it can be made recursive :) On Aug 9, 8:17 pm, Dave dave_and_da...@juno.com wrote: @Ankuj: Yeah, but he asked for it to be recursive. Yours is iterative. Dave On Aug 9, 9:56 am, Ankuj Gupta ankuj2...@gmail.com wrote: we can do it in logn by using binary search

[algogeeks] Re: need a pgm pls help me

2011-08-09 Thread Don
#include stdio.h #include stdlib.h int main() { char inFileName[80]; char outFileName[80]; int numSegments; int bytesPerSegment; printf(Enter file name:); fgets(inFileName,80,stdin); printf(Enter number of segments:); scanf(%d, numSegments); FILE *f = fopen(inFileName, rb);

Re: [algogeeks] Amazon question.

2011-08-09 Thread programming love
*Executing code with printf's for each iteration for better understanding.* #includestdio.h main(){ int n, i, j, k, t1=0, t2=0, t3, a[30]; printf(Enter the number of elements\n); scanf(%d, n); for(i=0; in; i++){ scanf(%d, a[i]); } for(i=0; in; i++) a[i]=a[i]*a[i]; k=n-1; i=0; j=k;

Re: [algogeeks] c question!

2011-08-09 Thread programming love
#includestdio.htypedef struct {char * a; }*nodeptr; main(){nodeptr h;h-a=programming;printf(hi %s\n, h-a);} @sidharth: thanks a lot for correcting me :) @aditya : no. there was some mistake; in the code i pasted above it's giving segmentation fault. Is it cause i'm initializing h without using

Re: [algogeeks] DBMS

2011-08-09 Thread Bipin kumar yadav
it should be 2^(m-1)-1 because in given m elements 1 element should be primary key, which will combined with other attributes to form super key. so there will be 2^(m-1) such subset now we subtract 1 for the phi.so this should be 2^(m-1)-1. correct me if i m wrong,,, -- You received this

Re: [algogeeks] solve this!

2011-08-09 Thread Prakash D
the solution will be 12C6* 6c3 * 6C2 because if you choose 6 people for the left side, then there is no option for the right side(i.e. we can select only the remaining 6 people for right side) also this 12C6 will provide all possible combinations for choosing 6 members for left or right and

[algogeeks] Re: Closest ancestor of two nodes

2011-08-09 Thread Don
tree closestSharedAncestor(tree root, tree node1, tree node2, int result) { tree returnValue = 0; if (root) { if (root == node1) result += 1; if (root == node2) result += 2; int sum = 0; tree returnLeft = closestSharedAncestor(root-left, node1, node2, sum); if

  1   2   >