<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>algorithms on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/algorithms/</link>
    <description>Recent content in algorithms on S Anand</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 11 Jan 2023 03:20:40 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/algorithms/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Picking books to read</title>
      <link>https://www.s-anand.net/blog/picking-books-to-read/</link>
      <pubDate>Wed, 11 Jan 2023 03:20:39 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/picking-books-to-read/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;Picking books to read&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/book-hunter-1.webp&#34;&gt;&lt;/p&gt;
&lt;p&gt;I add book recommendations to my &lt;a href=&#34;https://www.goodreads.com/review/list/39713492-s-anand?order=d&amp;amp;ref=nav_mybooks&amp;amp;shelf=to-read&amp;amp;sort=avg_rating&#34;&gt;GoodReads – To-read list&lt;/a&gt;. Then I sort by rating and pick the first one I like to read.&lt;/p&gt;
&lt;p&gt;In 2023, I&amp;rsquo;m &lt;a href=&#34;https://www.s-anand.net/blog/my-year-in-2022/&#34;&gt;reshaping my environment&lt;/a&gt;. Picking books I usually won&amp;rsquo;t pick. (Read &lt;a href=&#34;https://www.goodreads.com/book/show/21913640-the-unknown-unknown&#34;&gt;The Unknown Unknown: Bookshops and the Delight of Not Getting What You Wanted&lt;/a&gt; if you want to be similarly inspired.)&lt;/p&gt;
&lt;p&gt;So here are 4 approaches I&amp;rsquo;m adding to my process.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Algorithmic&lt;/strong&gt;. Sort &lt;a href=&#34;https://www.kaggle.com/datasets/bahramjannesarr/goodreads-book-datasets-10m&#34;&gt;Kaggle books&lt;/a&gt; based on popularity, rating, and age. Pick the top 10 (or 50)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serendipitous&lt;/strong&gt;. Go to bookstores and libraries. Pick the most popular books&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Award-winning&lt;/strong&gt;. Pick from the &lt;a href=&#34;https://en.wikipedia.org/wiki/Pulitzer_Prize&#34;&gt;Pulitzer&lt;/a&gt;, &lt;a href=&#34;https://en.wikipedia.org/wiki/Booker_Prize&#34;&gt;Booker&lt;/a&gt;, &lt;a href=&#34;https://en.wikipedia.org/wiki/Nobel_Prize_in_Literature&#34;&gt;Nobel&lt;/a&gt;, &lt;a href=&#34;https://en.wikipedia.org/wiki/Hugo_Award&#34;&gt;Hugo&lt;/a&gt;, and other &lt;a href=&#34;https://en.wikipedia.org/wiki/List_of_literary_awards&#34;&gt;award&lt;/a&gt; winners&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Challenges&lt;/strong&gt;. Pick from &lt;a href=&#34;https://www.popsugar.com/entertainment/reading-challenge-2023-49013480&#34;&gt;Popsugar&lt;/a&gt;, &lt;a href=&#34;https://bookriot.com/read-harder-2023/&#34;&gt;Book Riot&lt;/a&gt;, &lt;a href=&#34;https://www.goodreads.com/genres/reading-challenge-2023&#34;&gt;Goodreads&lt;/a&gt;, &lt;a href=&#34;https://www.the52book.club/2023-reading-challenge/&#34;&gt;The 52 Book Club&lt;/a&gt;, and other &lt;a href=&#34;https://www.girlxoxo.com/the-2023-master-list-of-reading-challenges/&#34;&gt;challenges&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;FYI, here are algorithmic results (for books with 100+ ratings and a 4+ average on Goodreads):&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Top rated books&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/24812&#34;&gt;The Complete Calvin and Hobbes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/8&#34;&gt;Harry Potter Boxed Set, Books 1-5 (Harry Potter, #1-5)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/95602&#34;&gt;Mark of the Lion Trilogy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/24814&#34;&gt;It&amp;rsquo;s a Magical World (Calvin and Hobbes, #11)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/54741&#34;&gt;Toda Mafalda&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/165068&#34;&gt;The Jesus Storybook Bible: Every Story Whispers His Name&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/70489&#34;&gt;There&amp;rsquo;s Treasure Everywhere (Calvin and Hobbes #10)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/862041&#34;&gt;Harry Potter Series Box Set (Harry Potter, #1-7)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/59715&#34;&gt;The Authoritative Calvin and Hobbes: A Calvin and Hobbes Treasury&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/10&#34;&gt;Harry Potter Collection (Harry Potter, #1-6)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Most popular books&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/2767052&#34;&gt;The Hunger Games (The Hunger Games, #1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/19063&#34;&gt;The Book Thief&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/4667024&#34;&gt;The Help&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/3&#34;&gt;Harry Potter and the Sorcerer&amp;rsquo;s Stone (Harry Potter, #1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/3636&#34;&gt;The Giver (The Giver, #1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/43641&#34;&gt;Water for Elephants&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/2429135&#34;&gt;The Girl with the Dragon Tattoo (Millennium, #1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/136251&#34;&gt;Harry Potter and the Deathly Hallows (Harry Potter, #7)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/28187&#34;&gt;The Lightning Thief (Percy Jackson and the Olympians, #1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/99561&#34;&gt;Looking for Alaska&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Oldest books&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/100779&#34;&gt;Reminiscences of a Stock Operator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/773951&#34;&gt;The Story of Ferdinand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/356321&#34;&gt;The Story of Babar (Babar, #1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/105097&#34;&gt;Ten Little Niggers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/153542&#34;&gt;Mike Mulligan and His Steam Shovel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/153540&#34;&gt;The Little House&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/156871&#34;&gt;Christianity and Liberalism&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/7777&#34;&gt;McElligot&amp;rsquo;s Pool&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/133526&#34;&gt;Blueberries for Sal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.goodreads.com/book/show/2549&#34;&gt;A Tear and a Smile&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    <item>
      <title>Managing the data deluge</title>
      <link>https://www.s-anand.net/blog/managing-the-data-deluge/</link>
      <pubDate>Sat, 10 Feb 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/managing-the-data-deluge/</guid>
      <description>&lt;p&gt;Peter Norvig&amp;rsquo;s brilliant talk on &lt;a href=&#34;mms://media.citris.berkeley.edu/Peter_Norvig&#34;&gt;Managing the Data Deluge&lt;/a&gt;. Among other things, he talks about how having lots of data is sometimes better than having a carefully designed algorithm.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Knuth Volume 4</title>
      <link>https://www.s-anand.net/blog/knuth-volume-4/</link>
      <pubDate>Mon, 24 Jul 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/knuth-volume-4/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.cs.utsa.edu/~wagner/knuth/&#34;&gt;The Art of Computer Programming, Volume 4&lt;/a&gt; by Donald Knuth. Pre-fascicles are available for download.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Math will rock your world</title>
      <link>https://www.s-anand.net/blog/math-will-rock-your-world/</link>
      <pubDate>Sat, 14 Jan 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/math-will-rock-your-world/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.businessweek.com/magazine/content/06_04/b3968001.htm&#34;&gt;It&amp;rsquo;s a good time to be a mathematician&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Compare Yahoo and Google searches</title>
      <link>https://www.s-anand.net/blog/compare-yahoo-and-google-searches/</link>
      <pubDate>Thu, 14 Apr 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/compare-yahoo-and-google-searches/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.langreiter.com/exec/yahoo-vs-google.html&#34;&gt;Compare Yahoo and Google searches&lt;/a&gt;. This site lets you compare the rankings of each site on identical searches with Yahoo and Google.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Prime factorisation algorithm</title>
      <link>https://www.s-anand.net/blog/prime-factorisation-algorithm/</link>
      <pubDate>Sun, 10 Nov 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/prime-factorisation-algorithm/</guid>
      <description>&lt;p&gt;An &lt;a href=&#34;http://www.sciencenews.org/20021026/bob9.asp&#34;&gt;update on the IIT-K prime factorisation algorithm&lt;/a&gt;. via Matthai Markose&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Tetris is NP-Hard</title>
      <link>https://www.s-anand.net/blog/tetris-is-np-hard/</link>
      <pubDate>Sat, 26 Oct 2002 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/tetris-is-np-hard/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://slashdot.org/article.pl?sid=02/10/24/2251234&amp;amp;mode=thread&amp;amp;tid=127&#34;&gt;Tetris is NP-Hard&lt;/a&gt;. Let me explain, in English, what that means.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The toughness of problems is how much time it takes to solve them.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Adding two 3-digit number takes less time than adding two 30-digit numbers, and hence is easier. Similarly, figuring out if a 3-digit number is prime or not is easier than a 30-digit number.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Some problems grow tough very quickly.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Adding two 30-digit numbers is 10-times slower than adding two 3-digit numbers. But checking if a 30-digit number is prime is &lt;strong&gt;several trillions&lt;/strong&gt; of times slower than checking a 3-digit number. That is because, to check if a number is prime, you need to repeatedly divide it by numbers smaller than it. For a 3-digit number, you need to divide by around 1,000 numbers. For a 30 digit number, it&amp;rsquo;s several trillions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Problems that grow tough at a constant rate are &amp;lsquo;P&amp;rsquo;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;What this means is: if you keep on doubling the number of digits, the problem repeatedly becomes twice as tough (or 3 times as tough, or whatever &amp;ndash; some constant rate). Adding of numbers is an example. (&amp;lsquo;P&amp;rsquo; stands for polynomial time.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Problems that grow tough at a constant rate &lt;strong&gt;if you already know how to solve them&lt;/strong&gt; are &amp;lsquo;NP&amp;rsquo;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For instance, to check if a 30-digit number is a prime, you needn&amp;rsquo;t check with &lt;strong&gt;all numbers&lt;/strong&gt; below the number. You just need to check with &lt;strong&gt;all primes&lt;/strong&gt; below the number. That takes about 10-times as much time as for a 3-digit number. Hence, if you knew which primes were below the number, it would be &amp;lsquo;P&amp;rsquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;lsquo;P&amp;rsquo; is a subset of &amp;lsquo;NP&amp;rsquo;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The real question is, are there any problems that are &amp;lsquo;NP&amp;rsquo; and not &amp;lsquo;P&amp;rsquo;. That is, are there problems for which you &lt;strong&gt;really&lt;/strong&gt; need to know how to solve the problem to be able to solve them in polynomial time? Or is it that we&amp;rsquo;ve just not been smart enough to come up with solutions that are fast enough? We don&amp;rsquo;t know. The first step is to make a list of &lt;a href=&#34;http://www.nada.kth.se/~viggo/problemlist/compendium.html&#34;&gt;NP problems that are not obviously in &amp;lsquo;P&amp;rsquo;&lt;/a&gt;. Then, we try converting these problems into each other in polynomial time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NP problems that can be converted into each other in polynomial time are &amp;lsquo;NP-hard&amp;rsquo;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So, if you solve any one of these &amp;lsquo;NP-hard&amp;rsquo; problems in polynomial time, you can solve all NP-hard problems in polynomial time. Figuring out the right moves in Tetris is one such problem.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Microsoft interview question</title>
      <link>https://www.s-anand.net/blog/microsoft-interview-question/</link>
      <pubDate>Mon, 15 Jan 2001 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/microsoft-interview-question/</guid>
      <description>&lt;p&gt;&amp;ldquo;Write a one-line C expression to determine if a number is a power of 2&amp;rdquo;. Microsoft is famous for &lt;a href=&#34;http://www-scf.usc.edu/~bondalap/ais/msqs.html&#34;&gt;asking such questions&lt;/a&gt; to their programmers. Or you might want to find out what the assembly code&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CWD
XOR AX, DX
SUB AX, DX
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;does. &lt;a href=&#34;http://www.ece.utexas.edu/~satti/brainteasers.html&#34;&gt;Satish&amp;rsquo;s site&lt;/a&gt; has the answer, but not the question. More questions: &lt;a href=&#34;http://www.acetheinterview.com/qanda/algorithms.html&#34;&gt;1&lt;/a&gt; &lt;a href=&#34;http://www.eecs.uic.edu/~skishenc/technical/technical4.htm&#34;&gt;2&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
