<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>O(blah)</title>
	<atom:link href="http://npeasy.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://npeasy.wordpress.com</link>
	<description>Computer science algorithms, puzzles, systems, and bad puns</description>
	<lastBuildDate>Sat, 27 Mar 2010 05:09:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='npeasy.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>O(blah)</title>
		<link>http://npeasy.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://npeasy.wordpress.com/osd.xml" title="O(blah)" />
	<atom:link rel='hub' href='http://npeasy.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Looking Inside a Bus Routing Algorithm</title>
		<link>http://npeasy.wordpress.com/2010/03/25/looking-inside-a-bus-routing-algorithm/</link>
		<comments>http://npeasy.wordpress.com/2010/03/25/looking-inside-a-bus-routing-algorithm/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 20:36:25 +0000</pubDate>
		<dc:creator>dgarg</dc:creator>
				<category><![CDATA[Graph Theory]]></category>
		<category><![CDATA[Path Finding]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">http://npeasy.wordpress.com/2010/03/25/looking-inside-a-bus-routing-algorithm/</guid>
		<description><![CDATA[Interesting animation and overview. Too bad more specific details on how the algorithm is designed and how it is checked for correctness are not shared. Still, cool to watch. http://flowingdata.com/2010/03/09/looking-inside-a-bus-routing-algorithm/<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=6&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Interesting animation and overview. Too bad more specific details on how the algorithm is designed and how it is checked for correctness are not shared. Still, cool to watch.</p>
<p><a href="http://flowingdata.com/2010/03/09/looking-inside-a-bus-routing-algorithm/">http://flowingdata.com/2010/03/09/looking-inside-a-bus-routing-algorithm/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/npeasy.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/npeasy.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/npeasy.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/npeasy.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/npeasy.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/npeasy.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/npeasy.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/npeasy.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=6&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://npeasy.wordpress.com/2010/03/25/looking-inside-a-bus-routing-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1a0f5eabeffd30f103bef0ac88d67f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dgarg</media:title>
		</media:content>
	</item>
		<item>
		<title>Introduction to BK-Trees</title>
		<link>http://npeasy.wordpress.com/2010/03/25/introduction-to-bk-trees/</link>
		<comments>http://npeasy.wordpress.com/2010/03/25/introduction-to-bk-trees/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 20:26:22 +0000</pubDate>
		<dc:creator>dgarg</dc:creator>
				<category><![CDATA[Trees]]></category>
		<category><![CDATA[BK-Trees]]></category>

		<guid isPermaLink="false">http://npeasy.wordpress.com/2010/03/25/introduction-to-bk-trees/</guid>
		<description><![CDATA[A nice introduction to BK-trees and its application for finding closest suggestions for potential misspelled words in a query. http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=4&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A nice introduction to BK-trees and its application for finding closest suggestions for potential misspelled words in a query.</p>
<p><a href="http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees">http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK-Trees</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/npeasy.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/npeasy.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/npeasy.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/npeasy.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/npeasy.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/npeasy.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/npeasy.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/npeasy.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=4&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://npeasy.wordpress.com/2010/03/25/introduction-to-bk-trees/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1a0f5eabeffd30f103bef0ac88d67f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dgarg</media:title>
		</media:content>
	</item>
		<item>
		<title>Facebook Puzzles!</title>
		<link>http://npeasy.wordpress.com/2010/01/27/facebook-puzzles/</link>
		<comments>http://npeasy.wordpress.com/2010/01/27/facebook-puzzles/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 20:42:32 +0000</pubDate>
		<dc:creator>dgarg</dc:creator>
				<category><![CDATA[Dynamic Programming]]></category>
		<category><![CDATA[Puzzles]]></category>
		<category><![CDATA[Facebook]]></category>

		<guid isPermaLink="false">http://npeasy.wordpress.com/?p=9</guid>
		<description><![CDATA[So I had been hearing about Facebook’s new puzzles page for a few weeks now… but it wasn’t until 2-3 days back when I actually got a chance to look at them. I gotta say — they were pretty interesting and FUN! In case you haven’t seen them, you can access them at http://www.facebook.com/careers/puzzles.php. Since it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=9&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I had been hearing about Facebook’s new puzzles page for a few weeks now… but it wasn’t until 2-3 days back when I actually got a chance to look at them. I gotta say — they were pretty interesting and FUN! In case you haven’t seen them, you can access them at <a href="http://www.facebook.com/careers/puzzles.php">http://www.facebook.com/careers/puzzles.php</a>.</p>
<p>Since it is IAP and I have some time to take a break from the other stuff I am doing, I thought I’d give some of these puzzles a shot. So far, I have tried LiarLiar, Breathalyzer, Gattaca, and FridgeMadness. My language of choice has been Java, after realizing that Python (my first choice) was excruciatingly slow when it came to data intensive processing. It also reminded me the value of importance of languages such as C and C++ which are no doubt the best choices for optimizing performance. Nevertheless, I stuck with Java because I am more comfortable with it and figured that coming up with a smarter algorithm (in time complexity) will win in any language.</p>
<p>One key realization I had with all these puzzles relates to the separation of two problems: the algorithm itself and the coding optimization. If it wasn’t for my 6.006 (Intro to algorithms) and 6.042 (Math for Computer Science) classes which I took in Fall ‘09, I would’ve been either clueless when approaching these problems or my solution would’ve been extremely inefficient. Thanks to the stuff I learned in those classes, the general approach usually jumped out at me within the first 5-10 mins of staring at it. Coding optimization was a greater challenge – this included: choosing the right data structures, deciding when to cache, and coming up with pruning techniques to save processing time. This was especially a challenge for Breathalyzer.</p>
<p><strong>LiarLiar</strong></p>
<p>Otherwise, LiarLiar could be modeled as creating a un-directed graph where a node was a person and an edge meant at least one of the persons accused the other of telling lies. From that point, you just need to run a BFS and color the nodes one of two colors so that no two nodes adjacent to each other have the same color. I originally made the coloring process recursive but after hitting stack overflow errors with large datasets, I made it iterative and it passed the bot.</p>
<p><strong>Gattaca</strong></p>
<p>I solved Gattaca using DP and I think the problem can be reduced to a longest subsequence problem in DP. I used the built in java Array.sort algorithm to first sort the gene prediction sets in the order of ascending end-index values. Then I used DP to keep track of a running max score as I looped from the beginning index of the DNA to the end index. I also found that storing each gene prediction in a separate object of its own and storing all such objects in a Array of PredSet objects helped in optimization. This approach is contrary to simply dealing with all primitive types and having to go through extra pains to manage repeating end-indexes. With PredSet, I could specify a simple compareTo function to customize how the data is sorted.</p>
<p><strong>Fridge Madness</strong></p>
<p>I thought FridgeMadness was pretty cool — the approach to this is similar to the stable marriage matching problem that I studied in 6.042. It was nice to actually implement the algorithm I learned only from a theoretical perspective.</p>
<p><strong>Breathalyzer</strong></p>
<p>Breathalyzer, unfortunately, still continues to annoy me. Algorithmically, it is based on the Levenshtein distance DP problem. But the big challenge here is optimization. Obviously, I cannot calculate the distance between each input word and all the words in the dictionary and find the best one. That would take ages. I’ve implemented basic pruning techniques:</p>
<ul>
<li>if the word is in the dictionary, return distance of 0 -OR- if the distance of a word has already been calculated, return the value from the alreadyProcessed table</li>
<li>calculate distance first from words starting with the same letters as that in the word</li>
<li>keep track of a running_min distance and if a word in the word list has a length which is out of the bounds of the target word +/- running_min, don’t calculate the distance</li>
<li>I modified my DP algorithm to calculate subproblems in a fashion where it could detect early whether the final distance is going to be greater than the running_min, and if so, it aborted early</li>
</ul>
<p id="aeaoofnhgocdbnbeljkmbjdmhbcokfdb-mousedown">Using the above, my results are accurate. Breathalyzer is a ’snack’ level problem. I wonder if time is the issue or if I am just not handling some edge cases. I am not sure. In any case, if you enjoy math/cs puzzles and have some spare time on your hands, definitely check this out. My next goal is to solve a ‘Buffet’. Facebull, perhaps?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/npeasy.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/npeasy.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/npeasy.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/npeasy.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/npeasy.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/npeasy.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/npeasy.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/npeasy.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=9&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://npeasy.wordpress.com/2010/01/27/facebook-puzzles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1a0f5eabeffd30f103bef0ac88d67f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dgarg</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://npeasy.wordpress.com/2010/01/25/hello-world/</link>
		<comments>http://npeasy.wordpress.com/2010/01/25/hello-world/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 04:58:05 +0000</pubDate>
		<dc:creator>dgarg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=1&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=npeasy.wordpress.com&amp;blog=12792705&amp;post=1&amp;subd=npeasy&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://npeasy.wordpress.com/2010/01/25/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d1a0f5eabeffd30f103bef0ac88d67f0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dgarg</media:title>
		</media:content>
	</item>
	</channel>
</rss>
