Re: [algogeeks] Coding..........

2011-07-22 Thread Puneet Gautam
@atul: can u pls explain ur code...? On 7/22/11, Puneet Gautam puneet.nsi...@gmail.com wrote: @atul: thanks..! On 7/22/11, atul purohit gonewiththe...@gmail.com wrote: @puuneet http://en.wikipedia.org/wiki/Sorting_algorithm#Stability On Fri, Jul 22, 2011 at 10:57 AM, Puneet Gautam

[algogeeks] Adove Question.........

2011-07-22 Thread UMESH KUMAR
Hi Given an array of size N that contain some elements, Write a program for finding all possible subset of size R . n i.e. P r Array :[1,2,3,4] n=4,r=3; Output should be: {1,2,3},(1,2,4).{2,3,4},{...} possible 24 sets. Thanks -- You

Re: [algogeeks] Coding..........

2011-07-22 Thread Abhi
@atul: can you please elaborate the algorithm you are using. -- 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/-/mLtfUz77JMIJ. To post to this group, send email

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread anonymous procrastination
@Abhi See every character in the string is read exactly once and hashed. So the complexity is O(n) only. Mistake you're doing is adding n/2 n times, but if you see in your example you have to add it twice only. -- AP -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Coding..........

2011-07-22 Thread Puneet Gautam
@atul: can u pls tell me how did u go about solving this in ur mind..? On 7/22/11, Abhi abhi123khat...@gmail.com wrote: @atul: can you please elaborate the algorithm you are using. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view

Re: [algogeeks] Adove Question.........

2011-07-22 Thread Puneet Gautam
@umesh: can R take any value from 1 to 3..? On 7/22/11, UMESH KUMAR kumar.umesh...@gmail.com wrote: Hi Given an array of size N that contain some elements, Write a program for finding all possible subset of size R . n i.e. P r Array :[1,2,3,4] n=4,r=3;

[algogeeks] Re: reverse a line.

2011-07-22 Thread anonymous procrastination
Heya, Someone please explain dinesh's approach with an example. I am not able to get the answer. Doing some mistake. -- AP -- 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] Coding..........

2011-07-22 Thread sunny agrawal
@atul Your algo is not stable http://www.ideone.com/DrV5J BTW what are u trying to do instead of posting a code please prefer posting a simple algorithm in text coding part is very easy once the correct algorithm is found On Fri, Jul 22, 2011 at 11:43 AM, Puneet Gautam

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Abhi
No, every character won't be read exactly once. -- 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/-/lU8COVBGWSwJ. To post to this group, send email to

Re: [algogeeks] Adove Question.........

2011-07-22 Thread UMESH KUMAR
yes R is actually size of subset that is always less than or equal to Size of the Array i.e r=n On Thu, Jul 21, 2011 at 11:16 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @umesh: can R take any value from 1 to 3..? On 7/22/11, UMESH KUMAR kumar.umesh...@gmail.com wrote: Hi Given an

Re: [algogeeks] Coding..........

2011-07-22 Thread saurabh singh
The approach by atul is maintaining partitions of array such that element left to it are even and right odd.Its an implementation of quick sort as discussed earlier.Its o(n) no doubt but its not stable. On Fri, Jul 22, 2011 at 11:51 AM, sunny agrawal sunny816.i...@gmail.comwrote: @atul Your

Re: [algogeeks] Coding..........

2011-07-22 Thread sunny agrawal
right.. To do it in O(n) we will need O(n) extra space. and without extra space we can use a divide and conquer approach with O(lgn) stack space On Fri, Jul 22, 2011 at 12:04 PM, saurabh singh saurab...@gmail.com wrote: The approach by atul is maintaining partitions of array such that element

Re: [algogeeks] Coding..........

2011-07-22 Thread UMESH KUMAR
Anybody try for maintain the stable of elements in O(n) as like Input is :{1,2,3,4,5,6,7} then Output should be (2,4,6,1,3,5,7) not.. {2,4,6,1,5,3,7} base on above discussion .. -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread Pankaj
N people are standing in a circle ,they start shooting the person standing *next to their neighbour.*If they start firing in this way , determine who will be alive after this sequence?? Just for confirming, if only 2 person are left, then out of guilt of killing other's does the person who has

Re: [algogeeks] Coding..........

2011-07-22 Thread Puneet Gautam
@sunny: how do u do it by Divide n conquer ...can u provide the algo...? On 7/22/11, UMESH KUMAR kumar.umesh...@gmail.com wrote: Anybody try for maintain the stable of elements in O(n) as like Input is :{1,2,3,4,5,6,7} then Output should be (2,4,6,1,3,5,7) not..

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread anonymous procrastination
Oh yes you're right. Understood the algo incorrectly. -- 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] Re: Microsoft Question!

2011-07-22 Thread Puneet Gautam
check this out: Considering all 4 bytes of int with no left or right shifts..!! ;) main() { unsigned int i,j,k,no=1; j=4; for(k=0;k32;k++) no*=2; no=no-j; cout\n The reverse isno; getch(); return 0; } On 7/22/11, nicks

Re: [algogeeks] Coding..........

2011-07-22 Thread sunny agrawal
Divide and Conquer Algorithm : Just like merge Sort of Quick sort...we just need to modify the merge step of merge sort or Partition step of Quick sort lets call our this method Arrange(); //just as merge step takes two sorted arrays and make one completely sorted one it takes 2 arrays which

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread sunny agrawal
yes, occording to conditions he has to :) On Fri, Jul 22, 2011 at 12:24 PM, Pankaj jatka.oppimi...@gmail.com wrote: N people are standing in a circle ,they start shooting the person standing *next to their neighbour.*If they start firing in this way , determine who will be alive after this

Re: [algogeeks] Coding..........

2011-07-22 Thread saurabh singh
For people who like the generic way,its merge sort only difference is where comp(a,b) returns true when a%2=1a%2=0. Rest its same. On Fri, Jul 22, 2011 at 1:12 PM, sunny agrawal sunny816.i...@gmail.comwrote: Divide and Conquer Algorithm : Just like merge Sort of Quick sort...we just need

[algogeeks] Re: Shooters in a circle

2011-07-22 Thread Interstellar Overdrive
Yes, the solution with Circular linked list works fine but it certainly involves great space considerations. I guess solving Josephus problem using dynamic programming more apt. It's O(n) as well. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread яαωαт Jee
@khattri and khurana: traverse the string once. suppose the string is abcdeabcdeabcde take a hashtable (initially set the items to -1) .now hash as per khurana's idea till no duplicate occurs.Instead of marking 1. mark the array index in the hashtable. so in the hash table, we have a=0 b=1 c=2 d=3

Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread Puneet Gautam
sorry guys.. dont check the above siolution.. its wrong...!!! misread it.. On 7/22/11, Puneet Gautam puneet.nsi...@gmail.com wrote: check this out: Considering all 4 bytes of int with no left or right shifts..!! ;) main() { unsigned int i,j,k,no=1; j=4; for(k=0;k32;k++)

Re: [algogeeks] Coding..........

2011-07-22 Thread Puneet Gautam
@sunny: got dat... On 7/22/11, saurabh singh saurab...@gmail.com wrote: So many why's..:) I was just trying to explain the queries about the divide and conquer asked above.+1 to u sunny. On Fri, Jul 22, 2011 at 1:26 PM, sunny agrawal sunny816.i...@gmail.comwrote: Yes thats true, but

Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread Shubham Maheshwari
x = 0; while( n ){ x = 1; x = x | ( n 1); n = 1; } return x; On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: sorry guys.. dont check the above siolution.. its wrong...!!! misread it.. On 7/22/11, Puneet Gautam puneet.nsi...@gmail.com wrote: check this out:

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread svm11
My algo for this prob: Maintain an array A for characters from a-z which stores the index of character encountered in the string. (initially all = -1) iterate over all the characters in the string maintaining low and high variables (initially both = 0) and max (initially = 0, stores length of

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Interstellar Overdrive
@rawat: your algo doesn't compute the length of the largest unique sub-string as far as I can infer or it needs further steps to be done. Abhishek Khattri -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Interstellar Overdrive
@svm11: Take the case with original string abcded output should be 5 but your algo will give the answer as 0. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

[algogeeks] subwords in a given word!

2011-07-22 Thread DeeJJ..!
Q)complexity to find subwords in a given word? ex: abcde ans: a b c d e ab bc cd de abc bcd cde abcd bcde abcde -- 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] subwords in a given word!

2011-07-22 Thread sunny agrawal
n+(n-1) +(n-2)++1 = O(n^2) On Fri, Jul 22, 2011 at 3:16 PM, DeeJJ..! suryaprakash...@gmail.com wrote: Q)complexity to find subwords in a given word? ex: abcde ans: a b c d e ab bc cd de abc bcd cde abcd bcde abcde -- You received this message because

[algogeeks] Re: subwords in a given word!

2011-07-22 Thread DeeJJ..!
@sunny...yaa..but can u just describe the algorithm..:) On Jul 22, 2:51 am, sunny agrawal sunny816.i...@gmail.com wrote: n+(n-1) +(n-2)++1 = O(n^2) On Fri, Jul 22, 2011 at 3:16 PM, DeeJJ..! suryaprakash...@gmail.com wrote: Q)complexity to find subwords in a given word? ex: abcde

Re: [algogeeks] Re: subwords in a given word!

2011-07-22 Thread shady
what algorithm, print it subsequently is there any ? On Fri, Jul 22, 2011 at 3:24 PM, DeeJJ..! suryaprakash...@gmail.com wrote: @sunny...yaa..but can u just describe the algorithm..:) On Jul 22, 2:51 am, sunny agrawal sunny816.i...@gmail.com wrote: n+(n-1) +(n-2)++1 = O(n^2)

[algogeeks] Printf evaluation

2011-07-22 Thread rShetty
#includestdio.h int main() { int i=1; printf(%d%d%d%d,++i,++i,++i,i++); return 0; } Explain how it will be evaluated ?? and the output obtained .. -- 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] Printf evaluation

2011-07-22 Thread Prem Krishna Chettri
Values will be Pushed to the Stack from left to right and Evaluated to be finally printed from the Stack. On Fri, Jul 22, 2011 at 4:01 PM, rShetty rajeevr...@gmail.com wrote: #includestdio.h int main() { int i=1; printf(%d%d%d%d,++i,++i,++i,i++); return 0; } Explain how it will

Re: [algogeeks] Printf evaluation

2011-07-22 Thread rajeev bharshetty
Some more explanation taking an example will be helpful take the example in the program. Thanks On Fri, Jul 22, 2011 at 4:03 PM, Prem Krishna Chettri hprem...@gmail.comwrote: Values will be Pushed to the Stack from left to right and Evaluated to be finally printed from the Stack. On Fri,

Re: [algogeeks] C OUTPUT HELP

2011-07-22 Thread Interstellar Overdrive
@nicks- Dev-cpp supports gcc compilers only. Just saying -- 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/-/tpDu2bt_tG8J. To post to this group, send email to

[algogeeks] Re: C OUTPUT HELP

2011-07-22 Thread Interstellar Overdrive
@T3rminal- Agreed. Thus the expressions like : a[i] = i++; , i=i++ - --i; are irrelevant -- 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/-/-lYHVFcDjXYJ. To

Re: [algogeeks] Re: Puzzle and solution

2011-07-22 Thread Rajeev Kumar
Please check this : http://www.techinterview.org/post/526313890/bad-king On Tue, Jul 19, 2011 at 8:43 PM, sagar pareek sagarpar...@gmail.com wrote: hey guys pls tell any other better solution ... On Tue, Jul 19, 2011 at 6:41 PM, sagar pareek sagarpar...@gmail.comwrote: Question :- Once

Re: [algogeeks] Adove Question.........

2011-07-22 Thread Piyush Sinha
initial call subset(a,n,r,0,0); printf(%d,count);//to know the value of nPr (no of subsets) * void subset(int a[],int n,int r,int j,int ind) { int i; if(ind==r) { printf({); for(i=0;iind;i++) printf(%d ,a[i]); printf(}\n); count++; }

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread surender sanke
here's O(1) x = n-pow(2,floor(log2(n))); pos = x*k+1; surender On Fri, Jul 22, 2011 at 1:19 PM, Interstellar Overdrive abhi123khat...@gmail.com wrote: Yes, the solution with Circular linked list works fine but it certainly involves great space considerations. I guess solving Josephus problem

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread surender sanke
small change here x = n-pow(2,floor(log(n))); pos = (x*k)%n+1; surender On Fri, Jul 22, 2011 at 4:54 PM, surender sanke surend...@gmail.com wrote: here's O(1) x = n-pow(2,floor(log2(n))); pos = x*k+1; surender On Fri, Jul 22, 2011 at 1:19 PM, Interstellar Overdrive

Re: [algogeeks] Printf evaluation

2011-07-22 Thread suresh srinivasan
Output: 5,4,3,1 *Explanation:* Since the brackets acts as right precedence, the execution of the statement is from right to left. The comma separates the individual. For i++, it prints the current 'i' value and increments it by 1. For ++i, it increments the value by 1 and prints the updated

Re: [algogeeks] Re: reverse a line.

2011-07-22 Thread Kamakshii Aggarwal
explanation for dinesh's algo. let the sting is:arr[]=my name is kamakshi first reverse the whole string by swapping characters from beginning and end strlen(arr)=19; now process till 19/2=9 swap(arr[0].arr[strlen-1]) now swap (arr[1],arr[strlen-2]); this way u will reverse the string in place.

[algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread яαωαт Jee
sorry, for the previous post, consider this... iterate the string using variable i 'low' is another variable that stores the index of previous occurrence of the character+1 initially, i=0 , low=0 max=i-low abcdedepoiuytu hashtable : a= -1 , b= -1, . . . z = -1 a=0 b=1 c=2 d=3 e=4 now, d comes

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Kamakshii Aggarwal
undefined behaviour. since value of i is changing more than once between two sequence points.. On Fri, Jul 22, 2011 at 5:42 PM, suresh srinivasan suree...@gmail.comwrote: Output: 5,4,3,1 *Explanation:* Since the brackets acts as right precedence, the execution of the statement is from

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Gaurav Popli
associativity rule is compiler dependent ...thats why undefined... On Fri, Jul 22, 2011 at 5:46 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: undefined behaviour. since value of i is changing more than once between two sequence points.. On Fri, Jul 22, 2011 at 5:42 PM, suresh srinivasan

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Abhinav Verma
There is NO universal way of doing this; every compiler does it differently, in its own ways. The problem here is that the above code changes the value of variable `i' many times between two sequence points. So you cant be sure as to what value `i' holds at what time!!! For more insight and a

Re: [algogeeks] Coding..........

2011-07-22 Thread Kunal Patil
@Sunny: Excellent explanation ( solution) !! -- 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] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2 i = 3, l = 0, h = 3, max = 3, A[c] = 3 i = 4, l = 0, h = 4, max = 4, A[d] = 4 i = 5, l = 0, h = 5, max = 5, A[e] = 5 i = 6, 'd' is encountered again, update l = A[d] = 4, new A[d] = 5, h = 6,

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread Kunal Patil
@surender: I assume you want to give general solution to Josephus problem in which we shoot every kth person...In that case formula for pos must be: pos = ( x*k )%n + (k-1) In current context, k=2...thus the formula which you gave also holds true..but not when k != 2 -- You received this

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Abhinav Verma
Its not the associativity which is undefined (Associativity has been defined *clearly* by the C Standards for each and every operator). Its the order of evaluation between 2 sequence pointhttp://en.wikipedia.org/wiki/Sequence_points which is undefined and hence compiler-dependent. On gcc version

Re: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav What do you thing the complexity of your algo is. And once you hit an duplicate, from where will you start again? On Fri, Jul 22, 2011 at 7:21 PM, vaibhavmitta...@gmail.com wrote: String is abcded l =0, h = 0 i = 1, l = 0, h = 1, max = 1, A[a]=1 i = 2, l = 0, h = 2, max = 2, A[b] = 2

Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav What do you think the complexity of your algo is. And once you hit an duplicate, from where will you start again? Try for this example abcdeaifjlbmnodpq. It will be still O(26*n) as at max, we would have to start from each letter and go forward maximum 26times( if we reach 26 then we have

Re: [algogeeks] Re: Shooters in a circle

2011-07-22 Thread surender sanke
@kunal patil ur right, i forgot to mention k=2. refer http://www.exploringbinary.com/powers-of-two-in-the-josephus-problem/ surender On Fri, Jul 22, 2011 at 7:21 PM, Kunal Patil kp101...@gmail.com wrote: @surender: I assume you want to give general solution to Josephus problem in which we

[algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
Hi All, In my last interview(given few months back), I was asked the following puzzle.. http://goo.gl/jrnpc Could you please tell me the solution for the same? Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @ jainvish.blogspot.com Success taste better when target achieved

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Pankaj
In my latest interview I encountered the following puzzle. There are 100 prisoners in the prison. All of them have either black or white cap. Jailer has asked them to stand in the queue such that nth guy can see caps of all the guys standing ahead of him, but he can not see his own cap. It

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
Have a look again. I traverse the string just once performing updation on variables low, high, max. I assume array operations to be O(1) (which they are). OVerall complexity is O(n).Once I hit a duplicate i change my low, high and A accordingly and move forward. Regards Vaibhav Mittal

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread SkRiPt KiDdIe
Worst case 99 get released. Is that correct..? -- 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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Pankaj
Skipp Riddle, Yes. 100th prisoner will risk his life. Similar puzzle was discuss recently. Does anyone remember the name or thread? ~ Pankaj On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: Worst case 99 get released. Is that correct..? -- You received this

Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: abcdeaifjlbmnodpq For this once you

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
*abcdea*ifjlbmnodpq For this once you encounter a at 6th position, You can update your max. Now You will have to do following operation. First clear all the hash. 2. You now can not start from 6th position. You will have to do back and start from 2 position that is b. Right? What is the maximum

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread chetan kapoor
josehus problem??? On Fri, Jul 22, 2011 at 7:57 PM, Pankaj jatka.oppimi...@gmail.com wrote: Skipp Riddle, Yes. 100th prisoner will risk his life. Similar puzzle was discuss recently. Does anyone remember the name or thread? ~ Pankaj On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe

Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM, vaibhavmitta...@gmail.com wrote: U hv got my algo completely wrong. Gimme a smaller test case so that i may wrk it out fr u. This one is freakingly large :P. Regards

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Pankaj
Chetan, No. How could you relate this problem with that? Do you find something similar? ~ Pankaj On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor chetankapoor...@gmail.comwrote: josehus problem??? On Fri, Jul 22, 2011 at 7:57 PM, Pankaj jatka.oppimi...@gmail.com wrote: Skipp Riddle, Yes.

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Gaurav Popli
may be im wrongbut i read it somewhere about it...the arguments of a function are evaluated in a associativity that is compiler dependent... for ex... printf(%d %d %d ,fun1(),fun2(),fun3()); the order in which functions are evaluated are compiler dependent On Fri, Jul 22, 2011 at 7:20

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM,

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM,

Re: Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on ideone. It should be easy and quick to code :) On Fri, Jul 22, 2011 at 7:59 PM,

Re: [algogeeks] Printf evaluation

2011-07-22 Thread shady
so many times such questions have come... behavior is entirely compiler dependent if you are preparing for interviews then believe me no one in the whole world will ask such questions to you. there's no point discussing it On Fri, Jul 22, 2011 at 8:15 PM, Gaurav Popli abeygau...@gmail.com

[algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread siva viknesh
@ankur.. as u said i m posting today :) :) 10 questions c output, one compiler based(CFG) ,one OS based (when reading internally it was just a simple percentage calculation question).. +3 for correct ans.. -2 for wrong ans...Damn it.. i dint notice d negative marking and

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread svm11
Sorry it gt posted thrice. On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote: https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of Technology Delhi. On , Pankaj jatka.oppimi...@gmail.com wrote: Vaibhav, Ok write your code and paste on

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread shady
what was it ? job interview questions or intern ? gcd can always be found in O(log(larger number)) , sorry, couldnt understand the complexity in that ? On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh sivavikne...@gmail.comwrote: @ankur.. as u said i m posting today :) :) 10

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread Prakash D
post the 10 questions plz On Fri, Jul 22, 2011 at 8:29 PM, shady sinv...@gmail.com wrote: what was it ? job interview questions or intern ? gcd can always be found in O(log(larger number)) , sorry, couldnt understand the complexity in that ? On Fri, Jul 22, 2011 at 8:22 PM, siva viknesh

Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread Pankaj
aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc output: Length of largest unique substring : 51 Sorry it gt posted thrice. On Jul 22, 7:50 pm, vaibhavmitta...@gmail.com wrote: https://ideone.com/kzo2L Regards Vaibhav Mittal Computer Science Netaji Subhas Institute Of

Re: [algogeeks] Coding..........

2011-07-22 Thread Gaurav Popli
an O(n) soln traveres the array...as you receive odd number put that index in queuewhen received an even numb check if queue is empty or not...if queue is empty the do nothing else swap with the head of the queue hope it worksit also maintains the stability of aarray... On Fri, Jul

Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread sagar pareek
gr8 shubham On Fri, Jul 22, 2011 at 1:42 PM, Shubham Maheshwari shubham@gmail.comwrote: x = 0; while( n ){ x = 1; x = x | ( n 1); n = 1; } return x; On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: sorry guys.. dont check the above siolution.. its

Re: Re: Fwd: [algogeeks] Re: Largest substring with unique characters

2011-07-22 Thread vaibhavmittal11
Thanx for pointitn out the case :) Hope dis wil wrk. https://ideone.com/0LNkW On , Pankaj jatka.oppimi...@gmail.com wrote: aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwzzyyzzabc output: Length of largest unique substring : 51 Sorry it gt posted thrice. On Jul 22, 7:50 pm,

Re: [algogeeks] Re: Puzzle and solution

2011-07-22 Thread sagar pareek
thanks its almost same :) i was hoping for a diff answer (if exists) On Fri, Jul 22, 2011 at 4:25 PM, Rajeev Kumar rajeevprasa...@gmail.comwrote: Please check this : http://www.techinterview.org/post/526313890/bad-king On Tue, Jul 19, 2011 at 8:43 PM, sagar pareek sagarpar...@gmail.comwrote:

Re: [algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread naveen ms
@siva viknesh:it would be of great help if u post the questions that u remember...(in that 10 questions)... with regards naveen -- 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] Re: Microsoft Question!

2011-07-22 Thread Shubham Maheshwari
thnx ... :D On Fri, Jul 22, 2011 at 9:19 PM, sagar pareek sagarpar...@gmail.com wrote: gr8 shubham On Fri, Jul 22, 2011 at 1:42 PM, Shubham Maheshwari shubham@gmail.com wrote: x = 0; while( n ){ x = 1; x = x | ( n 1); n = 1; } return x; On Fri, Jul 22, 2011 at 1:31 PM,

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Shubham Maheshwari
could some1 plz post the xplainations ... On Fri, Jul 22, 2011 at 8:04 PM, Pankaj jatka.oppimi...@gmail.com wrote: Chetan, No. How could you relate this problem with that? Do you find something similar? ~ Pankaj On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor

[algogeeks] Re: MICROSOFT!!!!

2011-07-22 Thread siva viknesh
both intern and interview. all 10 ques were MCQ type os based : 1. u ve a disk , 1 represents a 'valid read' (I forgot d exact term!!!) and 0 represents 'invalid read' gn. a hexadecimal string DFE00454AB ... find the nearest percentage of valid read? 2. gn. a CFG s-AB A-a|BaB B-bb

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread aditi garg
I think this can be answered like dis... let us say that the persons have decided amongst themselves that if the the number of people wearing white in front of dem is even he wud say white and if odd he wud say black Now suppose the 100th person counts the number of hats and finds it to be

Re: [algogeeks] Re: subwords in a given word!

2011-07-22 Thread Shubham Maheshwari
how are you gonna do it if the originl strng contains repeated letters ... On Fri, Jul 22, 2011 at 3:33 PM, shady sinv...@gmail.com wrote: what algorithm, print it subsequently is there any ? On Fri, Jul 22, 2011 at 3:24 PM, DeeJJ..! suryaprakash...@gmail.comwrote: @sunny...yaa..but

Re: [algogeeks] Re: Microsoft Question!

2011-07-22 Thread naveen ms
thank u:) -- 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

[algogeeks] explain plzz:output in file old.out

2011-07-22 Thread geek forgeek
#includestdio.h main() { FILE *fp; char a; fp=fopen(old.out,w); if(fp==0) printf(File opening error); else { for(scanf(%c,a);a!=EOF;scanf(%c,a)) fprintf(fp,%c,a); fclose(fp); fp=fopen(old.out,r); while(!feof(fp))

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread shady
what kind of joke is this ? On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek geekhori...@gmail.comwrote: #includestdio.h main() { FILE *fp; char a; fp=fopen(old.out,w); if(fp==0) printf(File opening error); else {

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread geek forgeek
@shady this is nt a joke.. sorry if i am asking too stupid question i m getting an infinite loop here. not getting how? On Fri, Jul 22, 2011 at 10:40 AM, shady sinv...@gmail.com wrote: what kind of joke is this ? On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek geekhori...@gmail.comwrote:

Re: [algogeeks] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Vishal Jain
I think Aditi's solution is correct. I was doing the same thing using XOR function... So basically I was saying to use XOR and interviewer was asking for something better... I could not find this solution... Thanks Aditi. Thanks Regards Vishal Jain MNo: +91-9540611889 Tweet @jainvis Blog @

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread shady
well you didn't mention the question, directly posted the code with no head-tail... wait will answer, it is not coming out of first loop On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek geekhori...@gmail.comwrote: @shady this is nt a joke.. sorry if i am asking too stupid question i m getting

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread shady
you are scanning from stdin therefore it is not coming out of first for loop... because your terminating condition is for EOF, which is -1( scanf returns -1 ) at the end. On Fri, Jul 22, 2011 at 11:34 PM, shady sinv...@gmail.com wrote: well you didn't mention the question, directly posted the

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread aditi garg
@shady. so in this case we shud use a!=-1 as the condition?? On Fri, Jul 22, 2011 at 11:37 PM, shady sinv...@gmail.com wrote: you are scanning from stdin therefore it is not coming out of first for loop... because your terminating condition is for EOF, which is -1( scanf returns -1 ) at the

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread LALIT SHARMA
No, actually , a is defined as char ... and comparing char with EOF ,, makes it go in infinte loop...as it never returns false. correct me if i am wrong... On Fri, Jul 22, 2011 at 11:41 PM, aditi garg aditi.garg.6...@gmail.comwrote: @shady. so in this case we shud use a!=-1 as the condition??

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread SkRiPt KiDdIe
I smell something BONe - Y :P -- 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

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread varun pahwa
For breaking the first loop after the input gives EOF. u can write it as. for(;~scanf(%c,a); ) On Fri, Jul 22, 2011 at 11:43 PM, LALIT SHARMA lks.ru...@gmail.com wrote: No, actually , a is defined as char ... and comparing char with EOF ,, makes it go in infinte loop...as it never returns

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread LALIT SHARMA
@script kiddle y u r rght ...i can smell too.. :P On Fri, Jul 22, 2011 at 11:52 PM, varun pahwa varunpahwa2...@gmail.comwrote: For breaking the first loop after the input gives EOF. u can write it as. for(;~scanf(%c,a); ) On Fri, Jul 22, 2011 at 11:43 PM, LALIT SHARMA

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread shady
@aditi the problem is scanf returns -1(EOF value) when it encounters the end of file, and inspite of comparing the return value of scanf he is comparing value of character 'a' which is not correct therefore the for loop should be like this : for(int

Re: [algogeeks] explain plzz:output in file old.out

2011-07-22 Thread geek forgeek
@shady and @varun ... i hav got it thanx both of u :) On Fri, Jul 22, 2011 at 11:31 AM, shady sinv...@gmail.com wrote: @aditi the problem is scanf returns -1(EOF value) when it encounters the end of file, and inspite of comparing the return value of scanf he is comparing value of character

[algogeeks] Re: C OUTPUT HELP

2011-07-22 Thread sumit
+1 to t3rminal On Jun 12, 11:38 pm, T3rminal piyush@gmail.com wrote: @all Stop guessing and making your own standards. C standards haven't defined anything (though in gcc arguments are processed from left to right) about processing arguments in a function call. And sentence like

[algogeeks] xplain output

2011-07-22 Thread geek forgeek
#includestdio.h void main() { int x; float t; scanf(%f,t); printf(%f\n,t); x=90; printf(%f\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x);

  1   2   >