<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Martin Ankerl &#187; rant</title>
	<atom:link href="http://martin.ankerl.com/category/rant/feed/" rel="self" type="application/rss+xml" />
	<link>http://martin.ankerl.com</link>
	<description>No movement is faster than no movement</description>
	<lastBuildDate>Tue, 13 Jul 2010 05:31:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Job Interview Question: Sorting Records</title>
		<link>http://martin.ankerl.com/2008/05/27/job-interview-question-sorting-records/</link>
		<comments>http://martin.ankerl.com/2008/05/27/job-interview-question-sorting-records/#comments</comments>
		<pubDate>Tue, 27 May 2008 11:22:36 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=154</guid>
		<description><![CDATA[Dev102.com has a few postings about interesting job interview question. His fifth challenge is this neat task: You are asked to sort a collection of records. The records are stored in a file on the disk, and the size of the file is much bigger than available memory you can work with. Assume a record [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dev102.com/">Dev102.com</a> has a few postings about interesting job interview question. <a href="http://www.dev102.com/2008/05/26/a-programming-job-interview-challenge-5-records-sorting/">His fifth challenge</a> is this neat task:</p>
<blockquote><p>You are asked to sort a collection of records. The records are stored in a file on the disk, and the size of the file is much bigger than available memory you can work with. Assume a record size is 10 bytes and file size is 1GB. you read and write data to/from disk in units of pages where each page is 1KB big. You have few (less than 10) available pages of physical memory. Assume you are given a method to compare two records.</p></blockquote>
<p>Here is how I would approach this problem. It was just a quick direct writeup of the thoughts that popped up in my mind:</p>
<ol>
<li>Easiest solution: use Unix&#8217;s <a href="http://www.softpanorama.org/Tools/sort.shtml">sort</a> tool, with <tt>-S</tt> option to specify max memory usage.
<li>If this is not allowed, the second easiest solution is to implement a simple <a href="http://en.wikipedia.org/wiki/Merge_sort">Merge sort</a>, and use multiple passes with one temporary file until everything is sorted.
<li>If speed is an issue, you can have a pre-pass before the merge sort that loads as much data junks into memory as possible, sorts this junk with <a href="http://en.wikipedia.org/wiki/Quick_Sort">Quicksort</a>, and write each sorted junk back into the temporary file.
<li>If you want to go even faster, you can go crazy with 10 passes at once and use a <a href="http://en.wikipedia.org/wiki/Sorting_network">sorting network</a> to merge these 10 streams. Here comes the point where you should benchmark before coding, because caching, harddisk properties etc. might have an enormous influence.
</ol>
<p>I believe this is a quite reasonable approach. It is important to have multiple solutions for a problem to select from, then you can choose the simplest one that works. This is the <a href="http://martin.ankerl.com/2006/01/25/software-design-principles/">Do The Simplest Thing That Could Possibly Work (DTSTTCPW)</a> &#8211; Principle. This approach is very important in test driven development, and in general a big part of the <a href="http://en.wikipedia.org/wiki/Scientific_method">scientific method</a> (see also <a href="http://en.wikipedia.org/wiki/Occam's_Razor">Occams&#8217; Razor</a>). If the simplest solution is enough, that&#8217;s great! If this is not enough, you can try again with the second simplest solution. Repeat until the problem is solved <img src='http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I have use this approach for a long time now, and its really productive. Never go for cool and interesting but complex solutions just because they are cool and interesting. These kind of solutions are just for your own ego. There are even <a href="http://www.codinghorror.com/blog/archives/000584.html">10 commandments for egoless programming</a>.</p>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=154&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2008/05/27/job-interview-question-sorting-records/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Project Development Phases</title>
		<link>http://martin.ankerl.com/2007/06/05/project-development-phases/</link>
		<comments>http://martin.ankerl.com/2007/06/05/project-development-phases/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 21:05:52 +0000</pubDate>
		<dc:creator>Martin Ankerl</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[project development]]></category>
		<category><![CDATA[quote]]></category>

		<guid isPermaLink="false">http://martin.ankerl.com/?p=89</guid>
		<description><![CDATA[The 6 stages of every project are: Enthusiasm. Disillusionment. Panic. The Search For The Guilty. The Punishment of the Innocent. Accolades for the Non-Participants. After 4 years of software development experience, I can say with much confidence that this is highly accurate.]]></description>
			<content:encoded><![CDATA[<p>The 6 stages of every project are:</p>
<blockquote>
<ol>
<li>Enthusiasm.</li>
<li>Disillusionment.</li>
<li>Panic.</li>
<li>The Search For The Guilty.</li>
<li>The Punishment of the Innocent.</li>
<li>Accolades for the Non-Participants.</li>
</ol>
</blockquote>
<p>After 4 years of software development experience, I can say with much confidence that this is highly accurate.</p>
<div style='clear:both'></div><img src="http://martin.ankerl.com/?ak_action=api_record_view&id=89&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://martin.ankerl.com/2007/06/05/project-development-phases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
