<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for fejj</title>
    <link>http://www.advogato.org/person/fejj/</link>
    <description>Advogato blog for fejj</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Sat, 18 May 2013 22:26:59 GMT</pubDate>
    <item>
      <pubDate>Wed, 28 May 2008 15:36:25 GMT</pubDate>
      <title>28 May 2008</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=178</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=178</guid>
      <description>&lt;p&gt;And here it is, your Moment of Zen:&#xD;
&lt;p&gt;&lt;i&gt;Those who assume the worst in other people, are by&#xD;
their very nature among the worst people.&lt;/i&gt;&#xD;
&lt;p&gt;&lt;i&gt;Those who assume the best in other people, are by&#xD;
their very nature among the best people.&lt;/i&gt;&#xD;
&lt;p&gt; -- Jeffrey Stedfast</description>
    </item>
    <item>
      <pubDate>Mon, 5 Mar 2007 19:56:18 GMT</pubDate>
      <title>5 Mar 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=177</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=177</guid>
      <description>&lt;a href="http://www.advogato.org/person/fzort/" &gt;fzort&lt;/a&gt;: I think you mean Binary&#xD;
Insertion&#xD;
Sort and not Bubble Sort. The idea would be to use another&#xD;
in-place sorting algorithm that doesn't get hit hard when&#xD;
attempting to sort a segment that &lt;i&gt;may&lt;/i&gt; already be&#xD;
pre-sorted. No reason to use anything slower than you have&#xD;
to, and so Binary Insertion Sort fits nicely.&#xD;
&lt;p&gt; For historical reasons, a Binary Insertion Sort was&#xD;
probably also used to eliminate recursive function call&#xD;
overhead as well as stack overflows.&#xD;
&lt;p&gt; Note that while the binary search portion of the Binary&#xD;
Insertion Sort algorithm is recursive, since it is tail&#xD;
recursive, it can be implemented in such a way as to even&#xD;
avoid having to use an internal stack.&#xD;
&lt;p&gt; See the last implementation discussed &lt;a&#xD;
href="http://jeffreystedfast.blogspot.com/2007/02/binary-insertion-sort.html"&gt;here&lt;/a&gt;&#xD;
for an example on how to do that.&#xD;
&lt;p&gt; Thanks for the link too, btw, I will be sure to check&#xD;
that out later when I get home from work!</description>
    </item>
    <item>
      <pubDate>Sun, 4 Mar 2007 17:12:20 GMT</pubDate>
      <title>4 Mar 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=176</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=176</guid>
      <description>&lt;p&gt;&lt;a href="http://www.advogato.org/person/haruspex/" &gt;haruspex&lt;/a&gt;: Hence my&#xD;
comment above that line,&#xD;
&lt;blockquote&gt;&lt;cite&gt;If your program makes heavy use of a&#xD;
sorting routine, you may want to consider implementing a&#xD;
tailored sort function rather than just using&#xD;
qsort().&lt;/cite&gt;&lt;/blockquote&gt;&#xD;
&lt;p&gt;By no means do I suggest writing your own low-level&#xD;
routines for no reason... but if your program is spending a&#xD;
lot of time sorting, then you might consider writing a&#xD;
tailored sort routine. Obviously this wouldn't make sense if&#xD;
sorting is barely even on the radar as far as time spent in&#xD;
your program.&#xD;
&lt;p&gt;Hopefully this clarifies my position and the intent of my&#xD;
wording (which I admit may have been unclear).&#xD;
&lt;p&gt;Note, also, that all of my entries in my blog series on&#xD;
sorting start off with an unoptimized version of the sort&#xD;
routine, implementing them as closely to the description of&#xD;
the algorithm as I can. From there, in each entry, I went on&#xD;
to describe my mode of thinking on how to achieve better&#xD;
performance (largely as an educational challenge to myself)&#xD;
- e.g. I never suggest pre-optimizing.&#xD;
&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; more on sorting &lt;a&#xD;
href="http://jeffreystedfast.blogspot.com/search/label/sorting"&gt;here&lt;/a&gt;.</description>
    </item>
    <item>
      <pubDate>Sun, 4 Mar 2007 14:58:52 GMT</pubDate>
      <title>4 Mar 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=175</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=175</guid>
      <description>Update: this article was moved: &lt;a href="http://jeffreystedfast.blogspot.com/2007/03/quick-sort.html" &gt;Quick&#xD;
Sort&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Sun, 4 Mar 2007 14:43:43 GMT</pubDate>
      <title>4 Mar 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=174</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=174</guid>
      <description>I came across something cool the other day that I thought&#xD;
I'd share: a 25-byte long integer sort routine (that is to&#xD;
say, the routine itself is only 25 bytes long).&#xD;
&#xD;
&lt;p&gt; &lt;p&gt; &lt;p&gt; &lt;p&gt; Here it is:&#xD;
&lt;pre style="font-family: courier new; font-size: 85%"&gt;&#xD;
;---------------------------------------------------------------&#xD;
; Sorts an array of ints. C-callable (small model). 25 bytes.&#xD;
; void sort (int n, int a[]);&#xD;
;&#xD;
; Courtesy of David Stafford.&#xD;
;---------------------------------------------------------------&#xD;
&lt;p&gt;      .model small&#xD;
      .code&#xD;
        public _sort&#xD;
&lt;p&gt;top:    mov     dx,[bx]   ; swap two adjacent ints&#xD;
        xchg    dx,[bx+2]&#xD;
        xchg    dx,[bx]&#xD;
&lt;p&gt;        cmp     dx,[bx]   ; in the right order?&#xD;
        jl      top       ; no, swap them back&#xD;
&lt;p&gt;        inc     bx        ; go to the next integer&#xD;
        inc     bx&#xD;
        loop    top&#xD;
&lt;p&gt;_sort:  pop     dx        ; get return address (entry point)&#xD;
        pop     cx        ; get count&#xD;
        pop     bx        ; get pointer&#xD;
        push    bx        ; restore pointer&#xD;
        dec     cx        ; decrement count&#xD;
        push    cx        ; save count&#xD;
        push    dx        ; save return address&#xD;
        jg      top       ; if cx &amp;gt; 0&#xD;
&lt;p&gt;        ret&#xD;
&lt;p&gt;       end&#xD;
&lt;/pre&gt;&#xD;
</description>
    </item>
    <item>
      <pubDate>Thu, 1 Feb 2007 17:22:35 GMT</pubDate>
      <title>1 Feb 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=173</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=173</guid>
      <description>&lt;p&gt;&lt;a&#xD;
href="http://www.advogato.org/person/fzort/diary.html?start=56"&gt;fzort&lt;/a&gt;:&#xD;
Ah, thank you for the explanation :)&#xD;
&lt;p&gt;I was just about to note that expanding on my previous&#xD;
estimation, a slightly better one would be:&#xD;
&lt;p&gt;&lt;b&gt;&lt;i&gt;r = (x &amp;gt;&amp;gt; 1) - (x &amp;gt;&amp;gt; 2) - (x &amp;gt;&amp;gt; 3) + (x &amp;gt;&amp;gt; 6)&lt;/i&gt;&lt;/b&gt;&#xD;
&lt;p&gt;And then of course I could perhaps expand on the (x &amp;gt;&amp;gt; 6)&#xD;
in a similar fashion to get an even more accurate result.&#xD;
&lt;p&gt;Anyways... kind of an interesting problem.</description>
    </item>
    <item>
      <pubDate>Thu, 1 Feb 2007 06:13:09 GMT</pubDate>
      <title>1 Feb 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=172</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=172</guid>
      <description>&lt;p&gt;Interesting interview questions:&#xD;
&lt;p&gt;&lt;b&gt;Q&lt;/b&gt;: What's a fast way to divide an integer by 7&#xD;
using the bit shift operator? (apparently asked by an &lt;a&#xD;
href="http://www.easports.com"&gt;EA Sports&lt;/a&gt; interviewer)&lt;br&gt;&#xD;
&lt;b&gt;A&lt;/b&gt;: I thought about this for a bit and came up&#xD;
with the following estimation:&#xD;
&lt;p&gt;&lt;b&gt;&lt;i&gt;r = (x &amp;gt;&amp;gt; 2) - (x &amp;gt;&amp;gt; 3) + (x &amp;gt;&amp;gt; 6);&lt;/i&gt;&lt;/b&gt;&#xD;
&lt;p&gt;I mostly mention this because I had my own interview&#xD;
today where I felt... well, less than adequate. Suffice it&#xD;
to say, my ability to figure out the Big-O notation for&#xD;
algorithms was less than stellar. I was also unable to come&#xD;
up with a solution for his webcrawler scenario, which was&#xD;
along the lines of "if you've got some huge number of pages&#xD;
to crawl, how could you prevent the crawler from scanning&#xD;
the same page multiple times?" to which I had to admit to&#xD;
him, I hadn't the slightest idea how to go about it (the&#xD;
prelude to this question had been "the simplest way to do&#xD;
such a thing if memory was not an issue" to which I replied&#xD;
I'd use a hash table, using the page urls as the key).</description>
    </item>
    <item>
      <pubDate>Fri, 26 Jan 2007 21:37:07 GMT</pubDate>
      <title>26 Jan 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=171</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=171</guid>
      <description>&lt;p&gt;Been listening to &lt;a&#xD;
href="http://www.modarchive.org/download.php/_/_too_fast.mod"&gt;Drivin'&#xD;
Too Fast&lt;/a&gt; lately, really has a nice groove to it.</description>
    </item>
    <item>
      <pubDate>Thu, 25 Jan 2007 16:54:51 GMT</pubDate>
      <title>25 Jan 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=170</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=170</guid>
      <description>&lt;p&gt;Amazing what a break from looking at code can do to help&#xD;
you fix a bug.&#xD;
&lt;p&gt;Back in 2004, I had been writing articles explaining&#xD;
different sorting algorithms, how they worked, and how to&#xD;
implement them in C (and in most cases, how to implement&#xD;
them more efficiently than the "standard textbook way").&#xD;
Well, I had gotten distracted around the time I had been&#xD;
working on an article for Quick Sort and never got around to&#xD;
finishing it. I remember having a bug in my QuickSort&#xD;
routine somewhere that I wasn't able to find after a few&#xD;
nights of looking at it and having had more pressing things&#xD;
to attend to, set it aside for later (but not before&#xD;
documenting a few test cases that failed and how they failed).&#xD;
&lt;p&gt;Well, yesterday, after coming across that code, I opened&#xD;
it up in my trusty Emacs editor and in just a few minutes&#xD;
had a solution... it was basically a simple one-off bug.&#xD;
&lt;p&gt;Not long after, I got a call from someone at Google who&#xD;
had seen my resume and repeatedly told me they found it&#xD;
"interesting". I have no idea what that means, exactly, but&#xD;
I take it that it's a Good Thing(tm) :)</description>
    </item>
    <item>
      <pubDate>Tue, 23 Jan 2007 18:54:55 GMT</pubDate>
      <title>23 Jan 2007</title>
      <link>http://www.advogato.org/person/fejj/diary.html?start=169</link>
      <guid>http://www.advogato.org/person/fejj/diary.html?start=169</guid>
      <description>&lt;p&gt;Thanks to &lt;a&#xD;
href="http://www.burtonini.com/blog/computers/lemonade-2007-01-23-13-10"&gt;Ross&lt;/a&gt;'s&#xD;
blog for informing me about &lt;a&#xD;
href="http://blog.dave.cridland.net/"&gt;Dave Cridland&lt;/a&gt;'s&#xD;
Push-IMAP projects (Polymer, Telomer) and the Lemonaide&#xD;
specs. This was quite an interesting read... I've been&#xD;
wanting something like this for years, it's really exciting&#xD;
stuff.&#xD;
&lt;p&gt;Despite what &lt;a&#xD;
href="http://pvanhoof.be/blog/index.php/2007/01/23/nokia-n880-fwd-misinformation"&gt;pvanhoof&lt;/a&gt;&#xD;
claims in his own response to this news, offline&#xD;
functionality is &lt;i&gt;not&lt;/i&gt; the hardest part of implementing&#xD;
an IMAP client.</description>
    </item>
  </channel>
</rss>
