<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Selection of Majority in O(n)</title><link>http://blogs.msdn.com/b/mohamedg/archive/2009/08/16/selection-of-majority-in-o-n.aspx</link><description>Selection algorithms are very useful in many instances, like finding the majority. Given an array of size n that contains a majority item (an item that's repeated more than n/2 times), we can find that item in O(n). Basically, we can consider it as a</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Selection of Majority in O(n)</title><link>http://blogs.msdn.com/b/mohamedg/archive/2009/08/16/selection-of-majority-in-o-n.aspx#9872736</link><pubDate>Mon, 17 Aug 2009 22:37:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9872736</guid><dc:creator>Mohamed Mahmoud El-Geish</dc:creator><description>&lt;p&gt;Actually, it's given that there exist such an item. There's a problem with the check you added that it may give you a false positive.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9872736" width="1" height="1"&gt;</description></item><item><title>re: Selection of Majority in O(n)</title><link>http://blogs.msdn.com/b/mohamedg/archive/2009/08/16/selection-of-majority-in-o-n.aspx#9872223</link><pubDate>Mon, 17 Aug 2009 14:34:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9872223</guid><dc:creator>Val</dc:creator><description>&lt;p&gt;Agree but then the algorithm should answer &amp;quot;There is no majority here&amp;quot;, i.e. it needs a little modification in the last statement:&lt;/p&gt;
&lt;p&gt;if( frequency &amp;gt; 0 )&lt;/p&gt;
&lt;p&gt;	Console.WriteLine( &amp;quot;Majority: &amp;quot; + candidate );&lt;/p&gt;
&lt;p&gt;else&lt;/p&gt;
&lt;p&gt;	Console.WriteLine( &amp;quot;There is no majority here.&amp;quot; );&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9872223" width="1" height="1"&gt;</description></item><item><title>re: Selection of Majority in O(n)</title><link>http://blogs.msdn.com/b/mohamedg/archive/2009/08/16/selection-of-majority-in-o-n.aspx#9871796</link><pubDate>Sun, 16 Aug 2009 23:42:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9871796</guid><dc:creator>Mohamed Mahmoud El-Geish</dc:creator><description>&lt;p&gt;No, majority is defined as the item that appears more than n/2 times.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://en.wikipedia.org/wiki/Majority"&gt;http://en.wikipedia.org/wiki/Majority&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What you do describe above is called Plurality&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://en.wikipedia.org/wiki/Plurality_"&gt;http://en.wikipedia.org/wiki/Plurality_&lt;/a&gt;(voting) &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9871796" width="1" height="1"&gt;</description></item><item><title>re: Selection of Majority in O(n)</title><link>http://blogs.msdn.com/b/mohamedg/archive/2009/08/16/selection-of-majority-in-o-n.aspx#9871749</link><pubDate>Sun, 16 Aug 2009 21:09:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9871749</guid><dc:creator>Zbyszek Swirski</dc:creator><description>&lt;p&gt;No way it works, sorry.&lt;/p&gt;
&lt;p&gt;Please consider input: 1,1,1,2,2,3,4,5,6,7 - majority is of course 1, but your alg gives response 7&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9871749" width="1" height="1"&gt;</description></item></channel></rss>