Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread Nitish Garg
I think Dave has posted the correct solution, you agree that if the first string is burned from both ends, it will burn out in exactly 30 minutes, right? Also when the first string burns out completely, the second string will still burn for 30 minutes more, at this time light the other end of

Re: [algogeeks] Explanation

2011-07-09 Thread Kamakshii Aggarwal
in my compiler,its giving is rajeev this is string 1 is ra On Fri, Jul 8, 2011 at 11:33 AM, rajeev bharshetty rajeevr...@gmail.comwrote: @Vishal : yes I can use strcpy, But What is the problem with memcpy(). On Fri, Jul 8, 2011 at 11:27 AM, Vishal Thanki

Re: [algogeeks] Explanation

2011-07-09 Thread Kamakshii Aggarwal
in my compiler,its giving is rajeev this is string 1 is ra On Fri, Jul 8, 2011 at 11:33 AM, rajeev bharshetty rajeevr...@gmail.comwrote: @Vishal : yes I can use strcpy, But What is the problem with memcpy(). On Fri, Jul 8, 2011 at 11:27 AM, Vishal Thanki

Re: [algogeeks] Re: find the integer

2011-07-09 Thread saurabh singh
Sort and take window of 2 while traversing, stop when the elements in the window do not match.The first one will be the non-repeated assuming only one such number exist in the array. complexity:o(nlogn) PS:Another possible solution is = 1. Form a BST.Add extra variable count to the node. 2.while

Re: [algogeeks] Explanation

2011-07-09 Thread oppilas .
There are few bugs in your code. You are going to copy 10 characters in string str1, so the ideal size of str should be 10+1(for null character). Now when u used memcpy, then it perfectly copies initial 10 characters in str1. You can see it in you current output. But when u use %s for printing

Re: [algogeeks] questions related to C

2011-07-09 Thread saurabh singh
#includestdio.h #includeerror.h #includemalloc.h #includestdlib.h void swap(void *p1,void *p2,const unsigned size) { char *buff=(char*) malloc(size*sizeof(char)); if(!buff) { perror(malloc); exit(11); } memcpy(buff,p1,size); memcpy(p1,p2,size); memcpy(p2,buff,size); free(buff); return; } int

Re: [algogeeks] questions related to C

2011-07-09 Thread John Hayes
generic swap can be written as - #define Swap(T, a, b) {T temp = a; a=b; b=temp;} this is working fine in gcc On Sat, Jul 9, 2011 at 1:45 PM, saurabh singh saurab...@gmail.com wrote: #includestdio.h #includeerror.h #includemalloc.h #includestdlib.h void swap(void *p1,void *p2,const

Re: [algogeeks] questions related to C

2011-07-09 Thread John Hayes
regarding question related to overflow int ovr_sum(int *sum,int a,int b) { *sum=a+b if(*sum0) return -1; //overflow else return 0; //no problem with the sum (overflow don't occur) } On Sat, Jul 9, 2011 at 2:05 PM, John Hayes agressiveha...@gmail.com wrote: generic swap can

Re: [algogeeks] array or matrix problems...anyone?

2011-07-09 Thread Nitish Garg
I think Strassen Algorithm is used to multiply Matrices efficiently. Read Cormen. -- 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/-/qO_1-pri7WIJ. To post to

[algogeeks] BIT MANIPULATION

2011-07-09 Thread Piyush Sinha
I found a good question to try for bit manipulation.Try it... :) Given an integer x, find out the smallest integer which has same number of set bits as x and is greater than x. For example if the input integer is 12 (1100) then your function should return 17(10001). If the input integer is

[algogeeks] puzzle

2011-07-09 Thread amit the cool
find d next: 91,110,134,_ -- 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,

[algogeeks] puzzle

2011-07-09 Thread amit the cool
6,24,60,120,_ -- 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

Re: [algogeeks] BIT MANIPULATION

2011-07-09 Thread Aman Goyal
Solutn: 1101000 Start from rightmost bit-leftmost bit Find the starting and ending 1’s positions, here 3 and 7 If any 0 bw them… while traversing.. (bitwise r-l).. make it 1 and other adjacent right ” 1” as “0”. And this is your new no. here 111 If you find no “0” in bw ( eg for

Re: [algogeeks] puzzle

2011-07-09 Thread Aman Goyal
210 for the last one you posted On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote: 6,24,60,120,_ -- 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

[algogeeks] Interview question

2011-07-09 Thread Gopi
Write code to move a set of elements (represented by start and end indexed) in an array to a given destination location (denoted by destination index). For example: Let say our array is {9, 7, 5, 8, 1, 5, 4, 8, 10, 1} move_set (array, start = 1, end = 3, destination = 8) should rearrage the

Re: [algogeeks] puzzle

2011-07-09 Thread Yogesh Yadav
91,110,134161 i guess 6,24,60,120210 On Sat, Jul 9, 2011 at 5:46 PM, Aman Goyal aman.goya...@gmail.com wrote: 210 for the last one you posted On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote: 6,24,60,120,_ -- You received this message because you are

Re: [algogeeks] Re: puzzle

2011-07-09 Thread Decipher
This question was asked by ST micro for hiring intern in my college . Here's the solution : Let the bottles of alcohol named 0 to 5 then - No.Binary Value 00 0 0 10 0 1 20 1 0 30 1 1 41 0 0 51 0 1 Mice - a b c Now make the mice drink alcohol

[algogeeks] Re: Interview question

2011-07-09 Thread Gopi
Hi Geeks Can anyone please comment on this. Let me know if the problem description is not clear enough. Thanks Gopi On Jul 9, 5:36 pm, Gopi kodaligopi...@gmail.com wrote: Write code to move a set of elements (represented by start and end indexed) in an array to a given destination location

Re: [algogeeks] BIT MANIPULATION

2011-07-09 Thread Yogesh Yadav
int count1=count2=0; given number=n; int m=n; //save in temp variable m while(m!=0) //count number of bits in given number { m=m (m-1); count1++; } m=n; //save in temp variable m while(count1!=count2) //check no. of bits same or not { m=m+1;

Re: [algogeeks] Re: Interview question

2011-07-09 Thread Yogesh Yadav
@gopi: i didnt really understand what u want to say... what start,end and destination denotes here?? u said it should start with 1 but in result it is starting with 9...plz explain ur question again On Sat, Jul 9, 2011 at 7:21 PM, Gopi kodaligopi...@gmail.com wrote: Hi Geeks Can anyone

Re: [algogeeks] Re: Interview question

2011-07-09 Thread sunny agrawal
Reverse elements of set from start to end Reverse elements of set from end+1 to destination Reverse elements of set from start to destination DONE O(n) On Sat, Jul 9, 2011 at 7:25 PM, Yogesh Yadav medu...@gmail.com wrote: @gopi: i didnt really understand what u want to say... what start,end

[algogeeks] Re: Interview question

2011-07-09 Thread Gopi
Hi Yogesh start and end denote the indexes where the set that is to be moved starts and ends in the given array. Destination index denotes the index in the array where the given set is to be moved. This needs some rearrangement of the array elements as shown in the example before. Hope that

[algogeeks] Re: Interview question

2011-07-09 Thread Gopi
@sunny That's excellent. Thanks Sunny. On Jul 9, 7:04 pm, sunny agrawal sunny816.i...@gmail.com wrote: Reverse elements of set from start to end Reverse elements of set from end+1 to destination Reverse elements of set from start to destination DONE O(n) On Sat, Jul 9, 2011 at 7:25

Re: [algogeeks] puzzle

2011-07-09 Thread vaibhav shukla
91,110,134,..163 ... 6,24,60,120..210 On Sat, Jul 9, 2011 at 6:48 PM, Yogesh Yadav medu...@gmail.com wrote: 91,110,134161 i guess 6,24,60,120210 On Sat, Jul 9, 2011 at 5:46 PM, Aman Goyal aman.goya...@gmail.com wrote: 210 for the last one you posted On Sat, Jul 9, 2011 at 4:33

[algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread Dumanshu
@oppilas: light the first string at both ends and in the middle. So it will burn completely in 15 min as the fire is advancing in 4 ways irrespective of the burn rate. when the first string is completely burnt, light the second string at both ends to get another 30 min. So, overall 45 min. On

Re: [algogeeks] array or matrix problems...anyone?

2011-07-09 Thread Kunal Patil
I had one in my MS apti... Given a randomly generated 2 d matrix find an element which occurs in all 3 rows... On Sat, Jul 9, 2011 at 2:47 PM, Nitish Garg nitishgarg1...@gmail.comwrote: I think Strassen Algorithm is used to multiply Matrices efficiently. Read Cormen. -- You received this

Re: [algogeeks] array or matrix problems...anyone?

2011-07-09 Thread Kunal Patil
@My post: matrix was randomly generated 3X3 matrix...(Not any 2D matrix) On Sat, Jul 9, 2011 at 9:08 PM, Kunal Patil kp101...@gmail.com wrote: I had one in my MS apti... Given a randomly generated 2 d matrix find an element which occurs in all 3 rows... On Sat, Jul 9, 2011 at 2:47 PM,

Re: [algogeeks] Re: find the integer

2011-07-09 Thread saurabh singh
code for my *second *solution http://www.ideone.com/oxDql http://www.ideone.com/oxDqlPoint out any bugs if you find. On Sat, Jul 9, 2011 at 12:43 PM, saurabh singh saurab...@gmail.com wrote: Sort and take window of 2 while traversing, stop when the elements in the window do not match.The

Re: [algogeeks] Re: find the integer

2011-07-09 Thread John Hayes
@saurabh.shouldn't be 5 also be in the outputi think u forgot to print the root value On Sat, Jul 9, 2011 at 9:27 PM, saurabh singh saurab...@gmail.com wrote: code for my *second *solution http://www.ideone.com/oxDql http://www.ideone.com/oxDqlPoint out any bugs if you find. On

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
Yes, these solution are valid. But for them the burning rate of each string must be constant. Each piece of string takes exactly an hour to burn, but the burn rate is not constant Can't we have a string which take 45 minutes to burn till half length. 0-L/2. And 15 min from L/2 to L. On Sat, Jul

[algogeeks] c doubt

2011-07-09 Thread Sangeeta
int main(){ int i; float a=5.2; char *ptr; ptr=(char *)a; for(i=0;i=3;i++) printf(%d ,*ptr++); } output: 102 102 -90 64.explain? -- 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.

Re: [algogeeks] c doubt

2011-07-09 Thread sunny agrawal
try to find out the binary representation of float value 5.2 On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta sangeeta15...@gmail.com wrote: int main(){ int i; float a=5.2; char *ptr; ptr=(char *)a; for(i=0;i=3;i++) printf(%d ,*ptr++); } output: 102 102 -90 64.explain? -- You received

[algogeeks] Re: Dynamic Programming Problem

2011-07-09 Thread Konstantin
Use complete search, add memoization and you have a top-down dynamic programming solution ready. - lets say we have division positions in an array cuts[] - start and end will identify the position of current cut (taken from cuts[] array) - initialize memo[][] array to INT_MAX, this is the place

Re: [algogeeks] GOOGLE Q

2011-07-09 Thread sunny agrawal
i have an O(nlgn) solution in mind using O(n^2) memory All the values can be thought as the following matrix (a0+b0) (a0+b1) (a0+b2).(a0+bn-1) (a1+b0) (a1+b1) (a1+b2).(a1+bn-1) .

Re: [algogeeks] puzzle

2011-07-09 Thread Nikita Jain
Can someone please suggest some good links to get questions related to number series ... Regards and Thanks Nikita Jain On Sat, Jul 9, 2011 at 8:25 PM, vaibhav shukla vaibhav200...@gmail.comwrote: 91,110,134,..163 ... 6,24,60,120..210 On Sat, Jul 9, 2011 at 6:48 PM, Yogesh Yadav

[algogeeks] Number Series

2011-07-09 Thread Nikita Jain
Can someone please suggest some questions to practise number series questions like 6,24,60,120 find the next no. in the series.. Regards Nikita -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] macro

2011-07-09 Thread Akshata Sharma
#define MESS junk main() { printf(MESS); } output is MESS. Why is it happening? -- 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] macro

2011-07-09 Thread parag khanna
#includestdio.h #define MESS junk void main() { printf(MESS); } use dis -- 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] macro

2011-07-09 Thread parag khanna
no text substitution occurs if the identifier is within the quotes -- 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] macro

2011-07-09 Thread John Hayes
refer KRit's clearly mentioned in it On Sun, Jul 10, 2011 at 12:12 AM, parag khanna khanna.para...@gmail.comwrote: no text substitution occurs if the identifier is within the quotes -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread Dumanshu
The above posted solution is independent of the burning rate. I am not counting the minutes using the half burnt string. Instead, the fire is running and when the whole string is burnt, I am using the time. Say u light up a string from both ends, then irrespective of burn rate it should give 30

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
Sorry, should have done it on paper properly!! Thanks! PS: below is the mail which I was about to write thinking that total time would not be 30 minutes if we burn it from both ends. Ok Suppose the length is 60meters. For 0-L/2 we have burn rate of 2/3m per minute. So, total time L/2/(2/3)=

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
light the first string at both ends and in the middle. So it will burn completely in 15 min as the fire is advancing in 4 ways irrespective of the burn rate. If we do the similar analysis for 15 min, I think we won't be able to do so!, Again if the length is of 60min. For 0-30 min, the burn rate

[algogeeks] Re: BIT MANIPULATION

2011-07-09 Thread Dave
@Piyush: See http://groups.google.com/group/algogeeks/msg/2b64c4f96fa3598e for a one-line algorithm. Dave On Jul 9, 4:23 am, Piyush Sinha ecstasy.piy...@gmail.com wrote: I found a good question to try for bit manipulation.Try it... :) Given an integer x, find out the smallest integer

Re: [algogeeks] puzzle

2011-07-09 Thread Abhishek Soni
is it 6,24,60,120,210,336,.. ? On Sat, Jul 9, 2011 at 4:03 AM, amit the cool amitthecoo...@gmail.comwrote: 6,24,60,120,_ -- 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] Re: BIT MANIPULATION

2011-07-09 Thread Piyush Sinha
@Dave..canu u explain ur algo to approach this formula?? On 7/10/11, Dave dave_and_da...@juno.com wrote: @Piyush: See http://groups.google.com/group/algogeeks/msg/2b64c4f96fa3598e for a one-line algorithm. Dave On Jul 9, 4:23 am, Piyush Sinha ecstasy.piy...@gmail.com wrote: I found a good

[algogeeks] Re: BIT MANIPULATION

2011-07-09 Thread Dave
@Piyush: The referenced web page includes a powerpoint presentation that explains it. Did you read the presentation before asking? If not, why not? Dave On Jul 9, 5:04 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote: @Dave..canu u explain ur algo to approach this formula?? On 7/10/11, Dave

[algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread Dumanshu
the string burns in an hour if lit from one end and string burns in 30 min if lit from both ends. This fact is based on - light up the string from either end it burns in 60 min. now heres the solution: Light up the first string from both ends and the second string from one end at the same time.

Re: [algogeeks] Re: String burn,measure time puzle

2011-07-09 Thread oppilas .
The solution of second puzzle is correct and for the first one I won't argue now :P.(sorry ) On 7/10/11, Dumanshu duman...@gmail.com wrote: the string burns in an hour if lit from one end and string burns in 30 min if lit from both ends. This fact is based on - light up the string from either

Re: [algogeeks] puzzle

2011-07-09 Thread varun pahwa
6,24,60,120,210,240.. On Sun, Jul 10, 2011 at 3:29 AM, Abhishek Soni ab.abhish...@gmail.comwrote: is it 6,24,60,120,210,336,.. ? On Sat, Jul 9, 2011 at 4:03 AM, amit the cool amitthecoo...@gmail.comwrote: 6,24,60,120,_ -- You received this message because you are subscribed to the

[algogeeks] find sol!!

2011-07-09 Thread Sriganesh Krishnan
(1*1!+2*2!+3*3!+4*4!+10*10!)/11! . is there any shortcut methods to solve such problems? find the odd one out... 13700, 1597, 326, 65, 16 , 6 , 2 and i have no clue to how to solve the second question -- You received this message because you are subscribed to the Google

[algogeeks] any tough aptitude questions!!!!

2011-07-09 Thread Sriganesh Krishnan
hey guys, do you know any website that offers really good aptitude questions...like interview aptitude questions!!! i think those are really tough than anything that we find in books -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] puzzle

2011-07-09 Thread aayush jain
plz give the logic of above series. -- 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

Re: [algogeeks] puzzle

2011-07-09 Thread Abhishek Soni
6,24,60,120,210,336.. Explaination: 0 + (6*1) = 6, 6 + (6*3) = 24, 24+ (6*6) = 60, 60+ (6*10) = 120, 120 + (6*15) = 210, 210 + (6*21) = 336,... On Sat, Jul 9, 2011 at 8:43 PM, aayush jain jain.aayus...@gmail.com wrote: plz give the logic of above series. -- You received this message

[algogeeks] Re: find sol!!

2011-07-09 Thread Dave
For the expression, I don't see a simple way. The result is slightly less than 1. For the second problem, 1597 is the only odd prime in the list, so it could be the odd one out. Dave On Jul 9, 10:15 pm, Sriganesh Krishnan 2448...@gmail.com wrote: (1*1!+2*2!+3*3!+4*4!+10*10!)/11! . is

Re: [algogeeks] Re: find the integer

2011-07-09 Thread saurabh singh
@John 5 is the number of inputs that the program will be expecting.Its not part of the array. On Sat, Jul 9, 2011 at 9:35 PM, John Hayes agressiveha...@gmail.com wrote: @saurabh.shouldn't be 5 also be in the outputi think u forgot to print the root value On Sat, Jul 9, 2011 at 9:27

Re: [algogeeks] Re: Sort - Consecutive Array in O(n)

2011-07-09 Thread Anantha Krishnan
If the range is (0,n) then we can solve in O(n) TC and O(1) SC. int checkconsequtive(int a[],int n){ if(n1) return 0; int min=a[0]; int max=a[0]; int i=0; for(i=1;in;i++) { if(a[i]min) min=a[i]; if(a[i]max) max=a[i]; }

Re: [algogeeks] Re: find sol!!

2011-07-09 Thread varun pahwa
for the first expression. summation (i = 1 to i = n ) on i * i ! gives ((n+1)! - 1). May be this may help in solving the problem. that is 1*1! = 2! - 1. 1*1! + 2*2! = 3! - 1. similarly, 1*1! + 2*2! + 3*3! ... + 10*10! = 11! - 1. On Sun, Jul 10, 2011 at 10:27 AM, Dave dave_and_da...@juno.com