<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Finding if an array is ordered</title>
	<atom:link href="http://www.codediesel.com/algorithms/finding-if-an-array-is-ordered/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codediesel.com/algorithms/finding-if-an-array-is-ordered/</link>
	<description>/* PHP &#38; MySQL Journal */</description>
	<lastBuildDate>Fri, 27 Jan 2012 16:39:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Sameer Borate&#8217;s Blog: Finding if an array is ordered : Dragonfly Networks</title>
		<link>http://www.codediesel.com/algorithms/finding-if-an-array-is-ordered/comment-page-1/#comment-1063</link>
		<dc:creator>Sameer Borate&#8217;s Blog: Finding if an array is ordered : Dragonfly Networks</dc:creator>
		<pubDate>Fri, 09 Jan 2009 10:58:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=162#comment-1063</guid>
		<description>[...] the CodeDiesel.com blog today Sameer has posted a quick code snippet that lets you see if a numeric array is already ordered correctly (useful for something like unit [...]</description>
		<content:encoded><![CDATA[<p>[...] the CodeDiesel.com blog today Sameer has posted a quick code snippet that lets you see if a numeric array is already ordered correctly (useful for something like unit [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xr</title>
		<link>http://www.codediesel.com/algorithms/finding-if-an-array-is-ordered/comment-page-1/#comment-1061</link>
		<dc:creator>Xr</dc:creator>
		<pubDate>Fri, 09 Jan 2009 09:23:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codediesel.com/?p=162#comment-1061</guid>
		<description>You can&#039;t make the time O(log N) since you have to check every element, which is precisely O(N).

Usually, a logarithmic time means O(N log N), which is worse than O(N) but much better than O(N²). For example, the best sorting algorithms have O(N log N) times (Quicksort with possible degeneration, Heap Sort), while naive ones have O(N²) times.

As for your algorithm:
 - You don&#039;t make the difference between strictly increasing (resp. strictly decreasing) and simply non-decreasing (resp. non-increasing).
 - AFAIK, it is only valid for arrays indexed by consecutive integers. A foreach would be better suited, keeping the previous element in a temporary variable (which could be more efficient than an array access as PHP does copy-on-write. This should be tested).
 - I&#039;d rather use multiple functions than a single parametrized one. This eliminates the need for a constant and limitates the needed logic.

Cheers.</description>
		<content:encoded><![CDATA[<p>You can&#8217;t make the time O(log N) since you have to check every element, which is precisely O(N).</p>
<p>Usually, a logarithmic time means O(N log N), which is worse than O(N) but much better than O(N²). For example, the best sorting algorithms have O(N log N) times (Quicksort with possible degeneration, Heap Sort), while naive ones have O(N²) times.</p>
<p>As for your algorithm:<br />
 &#8211; You don&#8217;t make the difference between strictly increasing (resp. strictly decreasing) and simply non-decreasing (resp. non-increasing).<br />
 &#8211; AFAIK, it is only valid for arrays indexed by consecutive integers. A foreach would be better suited, keeping the previous element in a temporary variable (which could be more efficient than an array access as PHP does copy-on-write. This should be tested).<br />
 &#8211; I&#8217;d rather use multiple functions than a single parametrized one. This eliminates the need for a constant and limitates the needed logic.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

