Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
for some inputs its giving junk as the answer and for others its giving segmentation fault could u plese explain why -- 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/-/E1TOuF3IY2EJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
if input starts with one or more characters from the string A telephone girl then it will give SEG FAULT because it scanf will try to write to CS, else initial value junk will be printed On Fri, Aug 5, 2011 at 6:28 PM, Lakshmi Prasad prasadlakshmi...@gmail.comwrote: for some inputs its giving junk as the answer and for others its giving segmentation fault could u plese explain why -- 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/-/E1TOuF3IY2EJ. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
@ Wastrel and Niteesh Mehra: I tried running the code: char *str; strcpy(str, junk); this gave a segmentation fault on Ubuntu 11.04 gcc-4.5.2 (32 bit OS) I think we should consider the general concept that a pointer cannot be used until it is assigned some memory. -- 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/-/aS_uYbtNWegJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
Right. But why does my compiler behave weirdly -- 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/-/iWbW5rOYO1EJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
Can anybody explain following questions from the above interview: Question: Output: int main() { char *str = “junk”; scanf (“%[A telephonic girl]”, str); printf (“%s\n”, str); return 0; } Question : Data Structure that can be useful for the calculation like ab mod m. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
The input for the above code was hello world. So the output would be hello. As the input will stop on reading 'w'. -- 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/-/oX1YmZcDR2MJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
Can any one explain the working of %[A telephonnic girl] *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Thu, Aug 4, 2011 at 12:25 PM, Nitish Garg nitishgarg1...@gmail.comwrote: The input for the above code was hello world. So the output would be hello. As the input will stop on reading 'w'. -- 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/-/oX1YmZcDR2MJ. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
its a regex. scanf will only accept characters in square brackets. On Thu, Aug 4, 2011 at 12:45 PM, muthu raj muthura...@gmail.com wrote: Can any one explain the working of %[A telephonnic girl] *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Thu, Aug 4, 2011 at 12:25 PM, Nitish Garg nitishgarg1...@gmail.comwrote: The input for the above code was hello world. So the output would be hello. As the input will stop on reading 'w'. -- 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/-/oX1YmZcDR2MJ. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
If you guys see the question properly it says, char *str = junk; str points to a read only memory and can't be written over with any method. Since there is no change in str. Hence the output will be junk, irrespective of any input. regex has been properly explained as above. -- 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/-/GLn4nI896ZkJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
@poised: Since it is read only memory junk will be the output if and only if we enter any string containing characters not inside []. If we try entering something present within [] i am getting segmentation fault. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Thu, Aug 4, 2011 at 6:21 PM, Poised~ dip10c...@gmail.com wrote: If you guys see the question properly it says, char *str = junk; str points to a read only memory and can't be written over with any method. Since there is no change in str. Hence the output will be junk, irrespective of any input. regex has been properly explained as above. -- 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/-/GLn4nI896ZkJ. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
This was the actual statement in the question : *char *str;* *strcpy(str,junk);* scanf(%[A telephonic girl],str); printf(%s,str); And the input was - hello world! . So , the output should be - hello. -- 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/-/NeCnfEo7WuQJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
@ Muthu raj: My bad, didn't check it properly. It is surely a runtime error. @ Niteesh Mehra: That code is even more wrong. without assigning any memory to str, how will you copy anything into it? This will definitely be a runtime error. http://ideone.com/erEXf -- 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/-/NrO6EJiurBkJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
thiis is theexact thing i thought abt segmentation error...but it is again system-dependent...if u wud try this on 7 or vista or XP...which are high on resources it wont give error to that...but there is definately an error in code... but y do u think tht junk wont be overwritten? s is simply a pointer to a memory address...contents can be changed whenever reqd...? On Thu, Aug 4, 2011 at 8:51 PM, Poised~ dip10c...@gmail.com wrote: @ Muthu raj: My bad, didn't check it properly. It is surely a runtime error. @ Niteesh Mehra: That code is even more wrong. without assigning any memory to str, how will you copy anything into it? This will definitely be a runtime error. http://ideone.com/erEXf -- 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/-/NrO6EJiurBkJ. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
@Poised : I remember that was the exact code and it works perfectly on CodeBlocks 10.05 (Gcc 4.5.1) on my 32bit win7. -- 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/-/3Y_3I-Ye2r4J. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
C:\Users\Niteesh\Documents\CodeBlocks Workspace\test3\main.c|7|*warning: 'str' is used uninitialized in this function|* * * But it runs just fine. -- 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/-/AHXdb0CaQcQJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
Niteesh, This is really strange. Going by the book, you can never use a pointer unless you assign some memory to it. I will try it on a Linux system and then again confirm it. -- 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/-/58dbQdanDv8J. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
How did the microsoft guy write tail without using seek()? one solution to this : continuously read file line by line and store each line in N*MAXLINE 2-D array(aux memory) until we get EOF. Is is the best approach? On Thu, Aug 4, 2011 at 11:26 PM, Poised~ dip10c...@gmail.com wrote: Niteesh, This is really strange. Going by the book, you can never use a pointer unless you assign some memory to it. I will try it on a Linux system and then again confirm it. -- 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/-/58dbQdanDv8J. 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 http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
ohh my bad... the array should be 1-D with N ptrs for each fgets() we put returned ptr to array and after getting loop back N times. On Thu, Aug 4, 2011 at 11:52 PM, mohit verma mohit89m...@gmail.com wrote: How did the microsoft guy write tail without using seek()? one solution to this : continuously read file line by line and store each line in N*MAXLINE 2-D array(aux memory) until we get EOF. Is is the best approach? On Thu, Aug 4, 2011 at 11:26 PM, Poised~ dip10c...@gmail.com wrote: Niteesh, This is really strange. Going by the book, you can never use a pointer unless you assign some memory to it. I will try it on a Linux system and then again confirm it. -- 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/-/58dbQdanDv8J. 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 http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- *MOHIT VERMA* -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package
The overall process: 1 Written, 3 rounds of interview 1) Written: Written was quite simple. The whole paper was divided into two sections. Section 1 was basically C, FAT and Data Structures Questions and Section 2 was for Coding, Testing and Design questions. Section A (10 questions) 1) Output of the following code : int main() { int x = 6; x = x ^ x; printf (“%d\n”, x); return 0; } 2) Output of following code : int main() { char*str; scanf (“%s”, str); switch (str) { case “Sun”: printf (“Sunday\n”); break; case “Mon”; printf(“Monday\n”); break; …… …… } } 3) Output : int main() { int x, y; printf (“%d\n”, scanf (“%d %d”, x, y)); return 0; } For input x = 100, y = 300 4) Output: int main() { char *str = “junk”; scanf (“%[A telephonic girl]”, str); printf (“%s\n”, str); return 0; } 5) 6) A function : Recursive version of “Repeated Squaring Algorithm”. So you have to answer what the function will return. 7) The following function will : double round(double x) { return (int)(x + 0.5); } a) Always work, b) Partially Work, c) Compilation Error, ….. 8) Output : int main() { int x = 6; int y = 10; int z; z += x – y; printf (“%d\n”, z); return 0; } 9) Static Variables 10) Output : Simple looping problem Section B 1) Code for Product Array Puzzle. (In best time and space complexities, robust, elegant code) 2) Test cases for Find in Wordpad. 3) Data Structure that can be useful for the calculation like ab mod m. Interview Round: 1) First Round: Directly with head (26 years experience). Very friendly, intelligent and great guy and a good observer too. He first asked, “Tell me about yourself.” Seriously speaking, I was not prepared for such HR questions. So I started with whatever came into my mind. After that, he gave me a state-event machine for validating a sentence and told me to code for that. So I wrote the code for that. The code was basically, with loops and conditions. So he further told me that if I add any new state (suppose for punctuations) in this machine, you will have to change your whole code. So “Is there any way you can improve it?” So I thought for 2-3 minutes and gave him a DP Solution. So It was like, for each state Si, when I get some event Ei, I will move to state Sj. So I preferred to create a table (2-D Array) for that. And after some time, I could recall that the table was “Predictive Parsing Table”. So I told him that it was predictive parsing table. He agreed and told me to write the code. I wrote the code and he was happy with that. After that, he told me to write the test cases for that. I gave him some test cases. And he further added some cases for that. Actually, for the Sentence validation, I just gave him test cases for English Language. So he told me why I didn’t think of Hindi or other language. Further he gave me some reasoning for that. Last question he asked me, “Do you have any questions for me?” I asked some questions and this was my first round. And called further for 2nd Round. 2) Second Round: Guy with 16 years Experience. He started with the question, “Why Microsoft?” I replied him. So he gave me first question to find the Least Common Ancestor for the given two numbers in a BST. So I thought for a moment and told him my approach. And he told me to write the code. I wrote the code and after that I gave the flaw in my own code. Actually, the way I solved the problem, did not verify whether given two values are present in the BST. Apart from that, my solution was recursive one. So he told me to write the Iterative solution, solving the verification problem too. I took 5 minutes to think and write the full code for this. He was satisfied with that. After that, he asked me “tail” command in UNIX and told me to give the approach and SEEK was not available to jump here and there in file. So first I gave him double pointer solution. But he told that this read the file two times. So I gave him one pointer solution with some auxiliary space. He was satisfied with the approach. And asked me some OS questions about Virtual Memory, Locks and Synchronization. This was the 2nd round. 3) Third Round: Guy with 6 years Experience. He gave his own introduction and then asked mine too. Question was to find the longest palindrome in the given string. I gave him solution after discussing for a long time with different approaches. I gave him two solutions. After that, he asked me some HR questions. Other guys were called for 4th round too. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,