tag:blogger.com,1999:blog-32064785.post391875116842676763..comments2024-03-28T17:06:30.318+05:30Comments on Freshers Interviews: Majority Elementchaitanyahttp://www.blogger.com/profile/05855949584266440305noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-32064785.post-75024776203013625032020-02-26T11:30:37.848+05:302020-02-26T11:30:37.848+05:30Excellent information, I like your post.
Best La...Excellent information, I like your post.<br /><br /><a href="https://www.dandrelectronix.com/pomona" rel="nofollow"><strong> Best Laptop Repair Shop in Pomona </strong></a> <br /> <br /> <a href="https://www.dandrelectronix.com/pomona" rel="nofollow"><strong>Best iPhone Repair Shop in Pomona</strong></a><br /><br /><a href="https://www.dandrelectronix.com/pomona" rel="nofollow"><strong>Best Cell Phone Repairing Services in Pomona</strong></a>Digital Marketinghttps://www.blogger.com/profile/05067530943434540895noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-31518093464773556842015-07-07T13:13:18.849+05:302015-07-07T13:13:18.849+05:30Basic Algo MOORE..
Step 1). initialize max_index=...Basic Algo MOORE..<br /><br />Step 1). initialize max_index=0; count=1;<br /><br />step 2).<br /><br />for(int i=1;i<A.size();i++)<br /><br />if(A.at(max_index)==A.at(i)) count++;<br />else count- -;<br /><br />if(count==0) {<br /><br />count=1;<br />max_index=i;<br />}<br />}<br /><br />return A.at(max_index);<br /><br /><br />here I m trying to so you demo...of Your eg..<br />20,7,3,7,1,7,7,7,7<br /><br />/**NMWPSMIE= Not matching with Previous Selected Max_Index Element */<br />A[0]=20 i=0) max_index=0; count=1;<br />A[1]=7 i=1) NMWPSMIE count--; count becomes=0; do this __ max_index=1; count=1;<br />A[2]=3 i=2) NMWPSMIE count--; count becomes=0; do this __ max_index=2; count=1;<br />A[3]=7 i=3) NMWPSMIE count--; count becomes=0; do this __ max_index=3; count=1;<br />A[4]=1 i=4) NMWPSMIE count--; count becomes=0; do this __ max_index=4; count=1;<br />A[5]=7 i=5) NMWPSMIE count--; count becomes=0; do this __ max_index=5; count=1;<br />A[6]=7 i=6) count++;<br />A[7]=7 i=7) count++;<br />A[8]=7 i=8)count++<br /><br />max_index=5;<br /><br />A[max_index]=7(as A[5]=7)<br /><br />you need check also this element also repeat more floor(A.size()/2)..<br />A.size()=9<br />Repeatation Needed Atleast=9/2+1=5<br />frequency of 7 = 6<br /><br />satisfy condition..So answer is 7....<br />if u still has doubt please mail me your doubt rameshc10695@gmail.com<br />or post here...facebook.com/groups/Novice.Programs.at.NITK/<br /><br />Happy Coding..................<br />Hope to see Your Reply Soon..................Anonymoushttps://www.blogger.com/profile/01247766934965059912noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-11058375661316462032015-07-07T13:11:55.914+05:302015-07-07T13:11:55.914+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/01247766934965059912noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-46937677926487739472010-09-09T14:12:07.465+05:302010-09-09T14:12:07.465+05:30On moore's approach :
what u think should be ...On moore's approach :<br /><br />what u think should be mode in : 12141516171833 ??<br /><br />it should be 1 but moore's approach will return 3.Saurabh Kumar Singhhttps://www.blogger.com/profile/11203979978640085921noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-5884739995776924072009-10-22T05:25:04.916+05:302009-10-22T05:25:04.916+05:30It seems in this case that the naive approach is a...It seems in this case that the naive approach is actually the best in terms of computations performed. O(N) is better than O(NlogN). I then wouldn't call it the naive approach but the smart approach. It's amazing how many problems Hash table solve in a very efficient manner.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32064785.post-42683391241937476322009-10-03T21:46:58.039+05:302009-10-03T21:46:58.039+05:30Good one. Found the solution here also http://gee...Good one. Found the solution here also http://geeksforgeeks.org/?p=503Devhttp://geeksforgeeks.org/noreply@blogger.comtag:blogger.com,1999:blog-32064785.post-5442272679827322962009-03-11T23:05:00.000+05:302009-03-11T23:05:00.000+05:30On the last method (Moore), what if the sequence i...On the last method (Moore), what if the sequence is:<BR/>20,7,3,7,1,7,7,7,7<BR/>, doesn't the algorithm fail?<BR/>counter = 0, e = ?<BR/>20 -> counter = 1, e = 20<BR/>7 -> counter = 0, e = 20<BR/>3 -> counter = 1, e = 3<BR/>7 -> counter = 0, e = 3<BR/>1 -> counter = 1, e = 1<BR/>7 -> counter = 0, e = 1<BR/>7 -> counter = 1, e = 7<BR/>7 -> counter = 2, e = 7<BR/>7 -> counter = 3, e = 7<BR/><BR/>counter = 3 < 9/2 = 4<BR/><BR/>Sorry if I misunderstood the algorithm, but i couldn't figure up this problem.<BR/><BR/>CheersAnonymousnoreply@blogger.com