tag:blogger.com,1999:blog-32064785.post6658323873041665171..comments2021-02-26T12:10:24.563+05:30Comments on Freshers Interviews: Microsoft Interview Questionschaitanyahttp://www.blogger.com/profile/05855949584266440305noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-32064785.post-74513496914471692512017-12-31T12:18:36.029+05:302017-12-31T12:18:36.029+05:30Reading interview questions prepares you for the u...Reading interview questions prepares you for the ultimate test of your career. You get to know what type of questions are asked in the companies. So you prepare accordingly. Thanks for sharing such an interesting blog posts.<br /><br />Best Regards, <br />Crish Watson<br /><a href="https://certwizard.com/" rel="nofollow">Pass Microsoft Certification Without Exam</a><br />Anonymoushttps://www.blogger.com/profile/01245682518957903743noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-21189461733109275792016-01-02T15:52:16.168+05:302016-01-02T15:52:16.168+05:30Great and Useful Article.
Java Online Training
On...Great and Useful Article.<br /><a href="http://wisenitsolutions.com/IT-Courses/Java-Training" title="Java Online Training" rel="nofollow">Java Online Training</a><br /><br /><a href="http://wisenitsolutions.com/IT-Courses/Java-Training" title="Online Java Course" rel="nofollow">Online Java Course</a><br /><br /><a href="http://wisenitsolutions.com/IT-Courses/Java-Training" title="Java Course Online" rel="nofollow">Java Course Online</a><br /><br /><a href="http://wisenitsolutions.com/IT-Courses/JavaEE-Training" title="J2EE training" rel="nofollow">J2EE training</a><br /><br /><a href="http://wisenitsolutions.com/IT-Courses/JavaEE-Training" title="online J2EE training" rel="nofollow">online J2EE training</a><br /><br /><a href="http://java360.co.in/best-recommended-books-for-spring-framework/" title="Best Recommended books for Spring framework" rel="nofollow">Best Recommended books for Spring framework</a><br /><br /><a href="http://athene.co.in/java-interview-questions/" title="Java Interview Questions" rel="nofollow">Java Interview Questions</a><br /><br /><br><br><br><br><br><br /><br /><a href="http://wisentechnologies.com/it-courses/java-training.aspx" title="Java Training Institutes in Chennai" rel="nofollow">Java Training Institutes in Chennai</a><br /><br /><a href="http://wisentechnologies.com/it-courses/java-training.aspx" title="Java Training in Chennai" rel="nofollow">Java Training in Chennai</a><br /><br /><a href="http://wisentechnologies.com/it-courses/java-training.aspx" title="J2EE Training in Chennai" rel="nofollow">J2EE Training in Chennai</a><br /><br /><a href="http://wisentechnologies.com/it-courses/java-training.aspx" title="java j2ee training institutes in chennai" rel="nofollow">java j2ee training institutes in chennai</a><br /><br /><a href="http://wisentechnologies.com/it-courses/java-training.aspx" title="Java Course in Chennai" rel="nofollow">Java Course in Chennai</a>navyahttps://www.blogger.com/profile/09650347706574609617noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-35771218277413699262015-07-21T20:53:01.507+05:302015-07-21T20:53:01.507+05:30Thank you for such a wonderful Information !!
Her...Thank you for such a wonderful Information !!<br /><b> Here is a list of Top LINUX INTERVIEW QUESTIONS<br><br /><a href="http://linux.amitmaheshwari.in/2015/07/veritas-cluster-interview-questions.html" rel="nofollow">Veritas Cluster Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/07/samba-server-interview-questions.html" rel="nofollow">SAMBA Server Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/linux-ftp-vsftpd-interview-questions.html" rel="nofollow">Linux FTP vsftpd Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/ssh-interview-questions-and-answers.html" rel="nofollow">SSH Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/apache-interview-questions.html" rel="nofollow">Apache Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/nagios-interview-questions.html" rel="nofollow">Nagios Interview questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2014/11/iptables-tutorials.html" rel="nofollow">IPTABLES Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/ldap-server-interview-questions.html" rel="nofollow">Ldap Server Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/lvm-interview-questions.html" rel="nofollow">LVM Interview questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/sendmail-server-interview-questions.html" rel="nofollow">Sendmail Server Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/yum-interview-questions-and-answers.html" rel="nofollow">YUM Interview Questions</a><br><br /><a href="http://linux.amitmaheshwari.in/2015/01/yum-interview-questions-and-answers.html" rel="nofollow">NFS Interview Questions</a><br><br />Read More at :- <a href="http://linux.amitmaheshwari.in" rel="nofollow">Linux Troubleshooting </a> </b>Domain KINGhttps://www.blogger.com/profile/14652297000553299207noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-48537611856681959472012-08-10T08:24:20.983+05:302012-08-10T08:24:20.983+05:30Hi
I read this post two times.
I like it so much...Hi<br /><br />I read this post two times.<br /><br />I like it so much, please try to keep posting.<br /><br />Let me introduce other material that may be good for our community.<br /><br />Source: <a href="http://interviewquestionstoask.info/microsoft-interview-questions/" rel="nofollow">Microsoft interview questions</a><br /><br />Best regards<br />HenryAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-63526614904030849592011-10-24T18:14:57.270+05:302011-10-24T18:14:57.270+05:30This section covers HR Interview Questions & A...This section covers HR Interview Questions & Answers for fresherâ€™s and experienced. It helps job seekers who are about to attend HR interview round. Please go through each question to find out a number of sample answers.<br /><br />Click On any question to find out a variety of sample answers:<br /><br /><a href="http://www.interview-made-easy.com/2008/12/personality-development.html" rel="nofollow"><b>Tips On Personality Development.</b></a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/hr1-tell-something-about-yourself.html" rel="nofollow">1) Sample Answers - Tell Me Something About Yourself.</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/hr2-what-are-your-strengths.html" rel="nofollow">2) Sample Answers - What Are Your Strengths?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/hr3-what-are-your-weakness.html" rel="nofollow">3) Sample Answers - What Are Your Weaknesses?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/can-you-work-well-under-pressure.html" rel="nofollow">4) Sample Answers - Can You Work Well Under Pressure Or deadlines?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/what-are-your-short-term-goals.html" rel="nofollow">5) Sample Answers - What Are Your Short Term Goals?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/hr6-what-are-your-long-term-goals.html" rel="nofollow">6) Sample Answers - What Are Your Long Term Goals?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/hr7-where-do-you-see-yourself-five.html" rel="nofollow">7) Sample Answers - Where Do You See yourself After Five Years?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/hr8-why-should-we-hire-you.html" rel="nofollow">8) Sample Answers - Why Should We Hire You?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/what-kind-of-salary-are-you-looking-for.html" rel="nofollow">9) Sample Answers - What Kind Of Salary Are You Looking For?</a><br /><br /><a href="http://www.interview-made-easy.com/2008/07/why-do-you-want-to-leave-your-current.html" rel="nofollow">10) Sample Answers - Why Do You Want To Leave Your Current Job/Organization/Company?</a>Uttam Agrawalhttps://www.blogger.com/profile/14782822449937945628noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-16573736521533931452011-07-31T02:40:12.665+05:302011-07-31T02:40:12.665+05:30Round 1 Q5: to have same elements in both the arra...Round 1 Q5: to have same elements in both the arrays, the sum of elements of each array should be equal as well as the sum of squares of each array should be equal (and of course both arrays should have equal no. of elements). Complexity O(n) :)sidharth guptahttps://www.blogger.com/profile/01794985527375852875noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-21895150234932643722010-09-06T14:45:26.750+05:302010-09-06T14:45:26.750+05:30In round 2 2nd queston:
#include
#include
main()
...In round 2 2nd queston:<br /><br />#include<br />#include<br />main()<br />{<br />char *a,ch;<br />int *b,i;<br />int* rep(char*);<br />clrscr();<br />printf("enter any string\n");<br /><br />gets(a);<br /><br />b=rep(a);<br />for(i=0;i<=25;i++)<br />{<br />if(b[i]!=0)<br />{<br /><br /> if(b[i]>1)<br /><br />printf("%c%d",tolower(i+65),b[i]);<br /><br /> else<br /> printf("%c",tolower(i+65));<br /> }<br /> }<br /><br />getch();<br />return(0);<br /><br />}<br /><br />int* rep(char* a)<br />{<br /> static int b[26];<br /> int i;<br /><br /> for(i=0;a[i]!='\0';i++)<br /> {<br /> if(isalpha(a[i]))<br /> {<br /> b[toupper(a[i])-65]++;<br /> }<br /><br /> }<br /> return(b);<br /> }Anonymoushttps://www.blogger.com/profile/02257833518554369892noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-79279549819023365772010-02-21T01:23:30.856+05:302010-02-21T01:23:30.856+05:30hey..
round 1 , question 5:-
build binary search t...hey..<br />round 1 , question 5:-<br />build binary search trees for both the array elements.<br />now perform in order traversal of both the trees, if the sequences are same, then both arrays contain same elements.<br />the complexity is O(n), the only catch here is that extra space for creating a tree is required, but there is no space constraint, so i guess this can be an alternative solution to the hashing approach.curioussss!!!!https://www.blogger.com/profile/01149148600196516384noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-20424574034445776582010-02-21T01:22:46.757+05:302010-02-21T01:22:46.757+05:30hey..
round 1 , question 5:-
build binary search t...hey..<br />round 1 , question 5:-<br />build binary search trees for both the array elements.<br />now perform in order traversal of both the trees, if the sequences are same, then both arrays contain same elements.<br />the time complexity is O(n), the only catch here is that extra space for creating a tree is required, but there is no space constraint, so i guess this can be an alternative solution to the hashing approach.curioussss!!!!https://www.blogger.com/profile/01149148600196516384noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-57818884539112395402009-06-04T22:40:35.559+05:302009-06-04T22:40:35.559+05:30May be if someone else has any idea to solve the q...May be if someone else has any idea to solve the ques 5 of Round 1 in O(n) or less time other than Hash Table approach then post it here...Unknownhttps://www.blogger.com/profile/14471034403640010314noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-18582011116968929562009-06-04T22:38:34.511+05:302009-06-04T22:38:34.511+05:30@ rakesh
for Round 1 ques 5
ur approach seems to ...@ rakesh <br />for Round 1 ques 5<br />ur approach seems to be completely wrong to me.<br />check ur approach for <br />set1={2,3,5,7} and set2={0,1,4,6}<br />by xoring the elements in each set we will get the answer = 3{011 in binary} but the number in both the sets are completely different.Unknownhttps://www.blogger.com/profile/14471034403640010314noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-69688144249496051152009-04-28T16:21:00.000+05:302009-04-28T16:21:00.000+05:30int main()
{
char s[]="aaabbbccccdee"...int main()<br />{<br /> char s[]="aaabbbccccdee",ch;<br /> int i,c=1;<br /> ch=s[0];<br /><br /> for(i=1;s[i];i++)<br /> {<br /> if(s[i]==ch)<br /> {<br /> c++;<br /> } <br /> else<br /> {<br /> printf("%c",ch);<br /> if(c>1)<br /> {<br /> printf("%d",c);<br /> c=1;<br /> }<br /> ch=s[i];<br /> } <br /> <br /> }<br /> printf("%c",ch); <br /> if(c>1)<br /> {<br /> printf("%d",c);<br /> }<br /><br /> getch();<br /> return 0;<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-37397713972641813692009-01-15T09:10:00.000+05:302009-01-15T09:10:00.000+05:30For round 1 question 5:if we xor all the elements ...For round 1 question 5:<BR/>if we xor all the elements of the first array and compare that with the result of the xor operation of the second array, we should be able to determine if both the arrays have the same elements.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-70067905453509177382008-12-19T06:53:00.000+05:302008-12-19T06:53:00.000+05:30The 4th approach doesn't really work, I am lol on ...The 4th approach doesn't really work, I am lol on my self, eg a1={1,1,1} a2={2,1,0}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-82565121336559688722008-12-17T11:08:00.000+05:302008-12-17T11:08:00.000+05:30I should mention that the summation of the differe...I should mention that the summation of the differences algorithm proposed in my previous comment works only when either the integers are all positive or negative.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-80586427908193267872008-12-17T06:38:00.000+05:302008-12-17T06:38:00.000+05:30Refering: Given two arrays of numbers, find if eac...Refering: Given two arrays of numbers, find if each of the two arrays have the same set of integers ? Suggest an algo which can run faster than NlogN ? <BR/><BR/>This can be done in different ways:<BR/><BR/>1 - Brute force: for each element in array1 check that element exists in array2. Note this would require to note the position/index so that duplicates can be handled properly. This requires O(n^2) with much complicated code, don't even think of it at all...<BR/><BR/>2 - Sort both lists, then check each element to see if they're identical. O(n log n) for sorting and O(n) to check so basically O(n log n), sort can be done in-place if messing up the arrays is not a problem, if not you need to have 2n size memory to copy the sorted list.<BR/><BR/>3 - Add the items and count from one array to a hashtable, then iterate through the other array, checking that each item is in the hashtable and in that case decrement count if it is not zero otherwise remove it from hashtable. O(n) to create a hashtable, and O(n) to check the other array items in the hashtable, so O(n). This introduces a hashtable with memory at most for n elements.<BR/><BR/>4 - Best of Best (Among the above): Subtract or take difference of each element in the same index of the two arrays and finally sum up the subtacted values. For eg A1={1,2,3}, A2={3,1,2} the Diff={-2,1,1} now sum-up the Diff = 0 that means they have same set of integers. This approach requires an O(n) with no extra memory. A c# code would look like as follows:<BR/><BR/><BR/> public static bool ArrayEqual(int[] list1, int[] list2)<BR/> {<BR/> if (list1 == null || list2 == null)<BR/> {<BR/> throw new Exception("Invalid input");<BR/> }<BR/><BR/> if (list1.Length != list2.Length)<BR/> {<BR/> return false;<BR/> }<BR/><BR/> int diff = 0;<BR/><BR/> for (int i = 0; i < list1.Length; i++)<BR/> {<BR/> diff += list1[i] - list2[i];<BR/> }<BR/><BR/> return (diff == 0);<BR/> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-5551083145510998202008-12-13T06:36:00.000+05:302008-12-13T06:36:00.000+05:30For Round 1, question 2 a possible representation ...For Round 1, question 2 a possible representation of the tree would look like:<BR/><BR/>For strings:<BR/>aaa<BR/>aab<BR/>aac<BR/>aad<BR/>aae<BR/>aaf<BR/>aag<BR/><BR/> a<BR/> __|...<BR/> |<BR/> a<BR/> |<BR/>_____________<BR/>| | | | | | |<BR/>a b c d e f g<BR/><BR/>With the above representation it can be implemented below at the end (c# code - not sure if it compiles as I wrote it in a notepad): <BR/><BR/>The first method creates a tree representation of the strings and the second one checks if the given string exists in the list of strings. The tree <BR/><BR/>is constructed with hashtable of hashtables data structure, but if the characters in the strings could be let's say a-z or A-Z, then the hashtable <BR/><BR/>can be replaced with 52 elements of array, with each element contains a bit (0 means no path or no string containing this char, 1 means has path) and <BR/><BR/>a pointer to another array of same structure and for this case we need a hash function to map the char to array index. <BR/><BR/>The tree using hashtable approach requires O(n) to construct the tree as we need to access all strings. But since we also parse each string to access <BR/><BR/>each characters that would add another O(m) time for each string. m represents the average length of the strings, therefore the time complexity is <BR/><BR/>O(n X m) which is O(n) if m is much...much...much less than n as n approaches to infinity. The above assertion is invalid in cases when m is close to <BR/><BR/>n as n approaches to infinity, but in reality that would not be the case. Therefore, construction the tree requires O(n), then look up is O(c) so <BR/><BR/>time it takes to search will be O(n). But once the tree is constructed any search would take an order of constant time O(c).<BR/><BR/>The whole idea of either Hashtable or the array approach is to speed up look up time, in either case look up will be done in a constant time. But the <BR/><BR/>hashtable approach would be a better solution in cases when among the 52 array elements only very few of them are used because we are wasting memory <BR/><BR/>besides the assumptions made. <BR/><BR/>Another approach that the writer of the article mentioned is to put all the strings in one hashtable, and then search the other string from the <BR/><BR/>hashtable. Now obviously one has to access all the strings to add them in a hashtable that would be done in linear time O(n), and then look up from a <BR/><BR/>hashtable takes a constant time O(c) therefore this approach would require O(n) time, so no much difference from the approach that uses a tree data <BR/><BR/>structure. <BR/><BR/>Let us see its memory utilization; best case scenario is if the strings are identical, in that case only one string will be added in the hashtable <BR/><BR/>but the worst would be if none of them are the same that means O(n) memory would be required to put the copy of the strings into the hashtable. But <BR/><BR/>the tree approach would reduce this memory usage significantly, because any sub strings starting from the beginning that are the same will share only <BR/><BR/>that substring space, that means if you have a strings array of 1000 elements and 20 char length each and the first 15 chars are the same for all the <BR/><BR/>1000 elements then you will have to use only 15 char spaces for the 1000 strings that would have required 15000 char spaces if implemented with the <BR/><BR/>hashtable approach.<BR/><BR/>Note: There is a char STRING_END_CHAR which is used to mark that the path from root to that char means that path represents a valid string. It is <BR/><BR/>very crucial to have this otherwise we wouldn't know what is valid string or not.<BR/><BR/>I would like to hear from any one any opinion and a better solution.<BR/><BR/>Here is the code:<BR/><BR/>public static char STRING_END_CHAR = '~';<BR/><BR/>public static Hashtable ConstructTree(string[] strings)<BR/>{<BR/> Hashtable mainht = new Hashtable();<BR/><BR/> foreach( string str in strings)<BR/> {<BR/> Hashtable ht = mainht;<BR/> foreach(char chr in str)<BR/> {<BR/> if(ht.ContainsKey(chr))<BR/> {<BR/> ht = ht[chr] as Hashtable;<BR/> }<BR/> else<BR/> {<BR/> Hashtable nht = new Hashtable();<BR/> ht.add(chr, nht);<BR/> ht = nht;<BR/> }<BR/> }<BR/> if(!ht.ContainsKey(STRING_END_CHAR))<BR/> {<BR/> ht.add(STRING_END_CHAR, true);<BR/> }<BR/> }<BR/> return mainht;<BR/>}<BR/><BR/><BR/>public static bool Exists(string[] strings, string str)<BR/>{<BR/><BR/> Hashtable ht = ConstructTree(strings);<BR/><BR/> foreach(char chr in str)<BR/> {<BR/> if(ht.ContainsKey(chr)) <BR/> {<BR/> ht = ht[chr] as Hashtable;<BR/> }<BR/> else<BR/> {<BR/> return false;<BR/> }<BR/> }<BR/><BR/> return ht.ContainsKey(STRING_END_CHAR);<BR/>}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-27562148919732670222008-10-23T06:30:00.000+05:302008-10-23T06:30:00.000+05:30While the interviewers are going to ask to see cod...While the interviewers are going to ask <BR/>to see code, they also want (as I would)<BR/>to see your thought processes as you write <BR/>the code. Let's pick question 2:<BR/><BR/>> Given 2 set of arrays of size N (sorted <BR/>> positive integers) find the median of the <BR/>> resultant array of size 2N.<BR/><BR/>Clearly you could combine these two arrays<BR/>into a single array, sort, and pick the <BR/>middle element. This requires additional <BR/>array space of size 2N and sorting this <BR/>larger array can be done in O(n log n). But<BR/>the aim is likely to find the most efficient<BR/>solution:<BR/><BR/>First, state your assumptions:<BR/><BR/>1. There may be duplicate integers.<BR/>2. The arrays A1 and A2 are sorted.<BR/>3. You can compare <, =, > <BR/><BR/>Second, you need to define what the median<BR/>value is. Since the total number 2N of <BR/>elements is even then define the median of <BR/>2N elements to be an element from either A1 <BR/>or A2 that is greater than or equal to N <BR/>elements in the combined array and lesser <BR/>than or equal to N elements in the combined <BR/>array. This means you will some ambiguity <BR/>because if all elements are distinct then <BR/>there are indeed two distinct elements that<BR/>could be selected as the median value.<BR/><BR/>Third, try to identify useful test cases <BR/>that will show your algorithm in practice,<BR/>and validate you have the right <BR/>implementation.<BR/>The following test cases come to mind:<BR/><BR/> A1={1,2,3,4,5}, A2={10,11,12,13,14}, M=5<BR/> A1={1,2,3}, A2={1,2,3}, M=2<BR/> A1={1,3,5}, A2={2,4,6}, M=3<BR/> A1={1,2,9,10}, A2={3,4,7,8}, M=4<BR/> A1={1,7,17,90}, A2={2,7,8,9}, M=7<BR/><BR/>The last test is interesting. Note that the<BR/>median value of each of the individual <BR/>Arrays is 7 and this is the final median of<BR/>the combined array! This is the best case <BR/>scenario. But then I'm struck by the <BR/>following idea: Since both arrays are <BR/>already sorted, you can "mark" the smaller <BR/>of the two first elements (if they are the<BR/>same mark both of them). Let's call this <BR/>operation "compare-and-mark". Once done, <BR/>advance (in one array or both) to the next<BR/>unmarked entry. And repeat until N numbers<BR/>are marked. These N numbers are the smallest<BR/>N numbers from the resulting set. This <BR/>computation has actually determined the <BR/>median, given our definition earlier. So <BR/>once N numbers are marked, we choose the <BR/>largest of these N numbers, which is a simple<BR/>comparison between the largest marked number<BR/>in A1 against the largest marked number in A2.<BR/><BR/>Here's some sample Java code:<BR/><BR/>public static int median (int[] a1, int[] a2) {<BR/> int i1 = 0, i2 = 0;<BR/> int marked = 0;<BR/> int n = a1.length; <BR/> while (marked < n) {<BR/> // when comparing, either advance both<BR/> // index values or just one.<BR/> if (a1[i1] == a2[i2]) {<BR/> marked += 2;<BR/> i1++;<BR/> i2++;<BR/> } else if (a1[i1] < a2[i2]) {<BR/> marked++;<BR/> i1++;<BR/> } else {<BR/> marked++;<BR/> i2++;<BR/> }<BR/> }<BR/> <BR/> // once done, i1 and i2 point to unmarked<BR/> // entries OR are past array bound.<BR/><BR/> // If last two entries are the same, we may<BR/> // have gone one too far and marked N+1 <BR/> // entries. Since the two numbers are the <BR/> // same in this case, it does not affect <BR/> // the result.<BR/><BR/> // all smallest elements are in a2.<BR/> if (i1 == 0) { return a2[i2-1]; } <BR/> <BR/> // all smallest elements are in a1.<BR/> if (i2 == 0) { return a1[i1-1]; } <BR/><BR/> // find larger (or equal) and return.<BR/> if (a1[i1-1] < a2[i2-1]){ return a2[i1-1];}<BR/> return (a1[i1-1]);<BR/>}<BR/><BR/>You can observe that the while loop is <BR/>executed no more than N times, thus this <BR/>algorithm is able to compute the median in <BR/>O(N) time.<BR/><BR/>For more ideas regarding the principles of <BR/>effective algorithms, including divide-<BR/>and-conquer, selecting the right data <BR/>structure, and greedy approaches, see the <BR/>"Algorithms in a Nutshell" book: <BR/><BR/> http://oreilly.com/catalog/9780596516246<BR/> <BR/>Best of luck!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-87207119067775634182007-09-28T13:53:00.000+05:302007-09-28T13:53:00.000+05:30HEYEXCELLENT!!HEY<BR/><BR/>EXCELLENT!!Anonymousnoreply@blogger.com