<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-3687361113178920589</atom:id><lastBuildDate>Sun, 08 Dec 2024 11:06:50 +0000</lastBuildDate><category>Linux</category><category>Solaris</category><category>CentOS</category><category>c++</category><category>programming</category><category>c</category><category>computer science</category><category>unix</category><category>Ubuntu</category><category>computer architecture</category><category>Fedora</category><category>Open Source</category><category>Scribe</category><category>System Admin</category><category>Ultra 45</category><category>build</category><category>dhcp</category><category>java</category><category>jobs</category><category>network</category><category>pc</category><category>tools</category><category>Algorithms</category><category>DVD</category><category>HDFS</category><category>HP-UX</category><category>Hadoop</category><category>Intel</category><category>Laptop</category><category>MacOS</category><category>Multiple Boot</category><category>NTP</category><category>OpenSolaris</category><category>Processor</category><category>SPARC</category><category>Scripting</category><category>Sorting</category><category>Troubleshooting</category><category>Vista</category><category>Windows</category><category>Windows XP</category><category>alarmclock</category><category>ant</category><category>backend</category><category>chinese</category><category>conversion</category><category>ctags</category><category>cygwin</category><category>diagram</category><category>firefox</category><category>font</category><category>ftp</category><category>installation</category><category>ipset</category><category>jpackage</category><category>log4j</category><category>matchit</category><category>mp4</category><category>network administration</category><category>openSUSE</category><category>performance</category><category>pipeline</category><category>pipelining</category><category>ssh</category><category>stack</category><category>terminal</category><category>tips</category><category>usb</category><category>vi</category><category>vim</category><category>virus</category><category>website</category><title>Knowns and Unknowns</title><description></description><link>http://knownsandunknowns.blogspot.com/</link><managingEditor>noreply@blogger.com (ChiMaster)</managingEditor><generator>Blogger</generator><openSearch:totalResults>44</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-483516994232642337</guid><pubDate>Mon, 07 Jul 2014 23:54:00 +0000</pubDate><atom:updated>2014-09-19T11:21:27.212-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">alarmclock</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Ubuntu Alarm Clock</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
I really like the old Ubuntu alarmclock instead of the new alarm-clock-applet. The reason is that alarmclock offers a way to save and load the alarm list which no other apps I know of can do. Today after rebooting, I couldn&#39;t see my alarms any more. After a few hours of try-and-error, I found the fix. It turned out that my alarmclock&#39;s config for some reason refused to open the app. So I moved ~/.config/alarmclock/alarms.conf to another folder, reinstalled alarmclock and reloaded my alarm list. Everything went to normal now, Hooray!&lt;/div&gt;
</description><link>http://knownsandunknowns.blogspot.com/2014/07/ubuntu-alarm-clock.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-2991136622984396403</guid><pubDate>Tue, 01 Jul 2014 18:10:00 +0000</pubDate><atom:updated>2014-07-02T09:42:03.360-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">ctags</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Adding another file type for ctags parsing</title><description>Normal ctags commands to support C++ parsing:&lt;br /&gt;
&lt;br /&gt;
$ ctags -R --c++-kinds=+cdefglmnpstuvx --fields=+iaS --extra=+q&lt;br /&gt;
&lt;br /&gt;
This will generate the ctags database from the following file types under the current directory:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;*.c++ *.cc *.cp *.cpp *.cxx *.h *.h++ *.hh *.hp *.hpp *.hxx *.C *.H&lt;br /&gt;
&lt;br /&gt;
(From ctags --list-maps)&lt;br /&gt;
&lt;br /&gt;
If another file type needs to be included for the parsing, for example you want to add *.inl file type to C++ language map, add the following line to ~/.ctags.&lt;br /&gt;
&lt;br /&gt;
--langmap=c++:+.inl&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
To check:&lt;br /&gt;
&lt;br /&gt;
$ ctags --list-maps | grep C++&lt;br /&gt;
C++&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *.c++ *.cc *.cp *.cpp *.cxx *.h *.h++ *.hh *.hp *.hpp *.hxx *.C *.H *.inl&lt;br /&gt;
&lt;br /&gt;
Run ctags again to regenerate the database with the support of *.inl files as well.&lt;br /&gt;
&lt;br /&gt;
$ ctags -R --c++-kinds=+cdefglmnpstuvx --fields=+iaS --extra=+q&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://knownsandunknowns.blogspot.com/2014/07/adding-another-file-type-for-ctags.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-2387726631465300497</guid><pubDate>Wed, 30 Apr 2014 00:19:00 +0000</pubDate><atom:updated>2015-11-05T11:34:50.829-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ipset</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">network</category><title>Using ipset</title><description>Finally got it to work. Nobody seems to have a complete and accurate solution for my case... So here it is.&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWhJd2gOrOedz1GvVh2RCvxC5FZeAPFdWAifhnyXilrz5OZlFr7iTds_wiE3rNwhQLa13ZD6KkN9E8s_NQVeo4ZVzbSUyx0sOxaI_lWRZqslHUWHwIPhs_ldDFIq5MXqs045iuSCQom6tZ/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; #include &amp;lt;iostream&amp;gt;  
 #include &amp;lt;thread&amp;gt;     // std::thread  
 #include &amp;lt;mutex&amp;gt;     // std::mutex  
 #include &amp;lt;assert.h&amp;gt;  
 extern &quot;C&quot; {  

 // Debian libipset libary is a C library. All the headers  
 // have to be enclosed in extern &quot;C&quot; brackets to have  
 // proper linkage  
 #include &amp;lt;libipset/session.h&amp;gt;      /* ipset_session_* */  
 #include &amp;lt;libipset/data.h&amp;gt;       /* enum ipset_data */  
 #include &amp;lt;libipset/parse.h&amp;gt;       /* ipset_parse_* */  
 #include &amp;lt;libipset/types.h&amp;gt;       /* struct ipset_type */  
 #include &amp;lt;libipset/ui.h&amp;gt;        /* core options, commands */  
 #include &amp;lt;libipset/utils.h&amp;gt;       /* STREQ */  
 }  
 // debian-ipset is not thread-safe. We&#39;re using  
 // a mutex to serialize the ipset calls.  
 std::mutex s_ipsetMutex;  
 // We&#39;re only adding a command/an element to the set,  
 // so the restore line no. remains 0  
 #define IPSET_SESSION_LINE_NO 0  
 int  
 ipsetAdd(std::string table, std::string set_type, uint32_t interval)  
 {  
  int32_t ret = 0;  
  const struct ipset_type *type = NULL;  
  enum ipset_cmd cmd = IPSET_CMD_ADD;  
  struct ipset_session *session;  
  // debian-ipset calls are not thread-safe. We&#39;re adding  
  // a mutex to serialize the calls.  
  s_ipsetMutex.lock();  
  ipset_load_types();  
  // Initialize an ipset session by allocating a session structure  
  // and filling out with the initialization data.  
  session = ipset_session_init(printf);  
  if (session == NULL)  
  {  
   printf(&quot;ipsetAdd: Cannot initialize ipset session for &quot;  
     &quot;set_type %s. aborting.\n&quot;, set_type.c_str());  
   ret = 1;  
  }  
  else  
  {  
   // Set session lineno to report parser errors correctly   
   ipset_session_lineno(session, IPSET_SESSION_LINE_NO);  
   // Parse string as a setname.  
   // The value is stored in the data blob of the session.  
   ret = ipset_parse_setname(session, IPSET_SETNAME, table.c_str());  
   if (ret == 0)  
   {  
    type = ipset_type_get(session, cmd);  
    if (!type)  
    {  
     printf(&quot;ipsetAdd: Failed to get the set type from Kernel &quot;  
       &quot;set_type=%s table=%s sess=%p cmd=%d\n&quot;, set_type.c_str(), table.c_str(),  
       session, cmd);  
     ret = 1;  
    }  
    else  
    {  
     // Parse string as a (multipart) element according to the settype.  
     // The value is stored in the data blob of the session.  
     ret = ipset_parse_elem(session, (ipset_opt)type-&amp;gt;last_elem_optional,  
                 set_type.c_str());  
     if (ret == 0)  
     {  
      // Put a given kind of data into the data blob and mark the  
      // option kind as already set in the blob.  
      ret = ipset_data_set(ipset_session_data(session), IPSET_OPT_TIMEOUT, &amp;amp;interval);  
      if (!ret)  
      {  
       // Execute a command  
       ret = ipset_cmd(session, cmd, IPSET_SESSION_LINE_NO);  
       if (ret)  
       {  
        printf(&quot;ipsetAdd: WARNING: Failed to execute &quot;  
          &quot;IPSET_CMD_ADD command. ipset exists? ret=%d set_type=%s table=%s\n&quot;,  
          ret, set_type.c_str(), table.c_str());  
        // Not an error condition  
        ret = 0;  
       }  
      }  
      else  
      {  
       printf(&quot;ipsetAdd: Failed to set timeout option. &quot;  
         &quot;ret=%d set_type=%s table=%s\n&quot;, ret, set_type.c_str(), table.c_str());  
      }  
     }  
     else  
     {  
      printf(&quot;ipsetAdd: Failed to parse element. &quot;  
        &quot;ret=%d set_type=%s table=%s\n&quot;, ret, set_type.c_str(), table.c_str());  
     }  
    }  
   }  
   else  
   {  
    printf(&quot;ipsetAdd: Failed to parse setname. &quot;  
      &quot;ret=%d set_type=%s table=%s\n&quot;, ret, set_type.c_str(), table.c_str());  
   }  
   // Finish the ipset session  
   if (ipset_session_fini(session) != 0)  
   {  
    printf(&quot;ipsetAdd: Failed to destroy ipset &quot;  
      &quot;session. ret=%d set_type=%s table=%s\n&quot;, ret, set_type.c_str(),  
      table.c_str());  
   }  
  } // else of if (session == NULL)  
  s_ipsetMutex.unlock();  
  return ret;  
 }  
 int main()  
 {  
  ipsetAdd(&quot;&lt;/code&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;my_ipset_table&quot;&lt;/code&gt;, &quot;127.0.0.1,62142,127.0.0.1&quot;, 600);  
  return 0;  
 }  


To build it:
$ g++ myipset.cpp -std=c++0x  -lipset -o myipset

Create your ipset first:
$ sudo ipset create my_ipset_table hash:ip,port,ip family inet maxelem 600000

Due to the fact that some of the ipset commands need special
capability to call or get valid return (e.g. ipset_type_get &amp;amp; ipset_cmd), you have to run it as root.
$ sudo myipset

To check it:
$ sudo ipset -l

&lt;/code&gt;&lt;/pre&gt;
Here is the C version of the same function:

&lt;br /&gt;
&lt;pre style=&quot;background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWhJd2gOrOedz1GvVh2RCvxC5FZeAPFdWAifhnyXilrz5OZlFr7iTds_wiE3rNwhQLa13ZD6KkN9E8s_NQVeo4ZVzbSUyx0sOxaI_lWRZqslHUWHwIPhs_ldDFIq5MXqs045iuSCQom6tZ/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt; #include &amp;lt;stdio.h&amp;gt;  
 #include &amp;lt;pthread.h&amp;gt;       
 #include &amp;lt;assert.h&amp;gt;  
 #include &amp;lt;libipset/session.h&amp;gt;      /* ipset_session_* */  
 #include &amp;lt;libipset/data.h&amp;gt;       /* enum ipset_data */  
 #include &amp;lt;libipset/parse.h&amp;gt;       /* ipset_parse_* */  
 #include &amp;lt;libipset/types.h&amp;gt;       /* struct ipset_type */  
 #include &amp;lt;libipset/ui.h&amp;gt;        /* core options, commands */  
 #include &amp;lt;libipset/utils.h&amp;gt;       /* STREQ */  
 // debian-ipset is not thread-safe. We&#39;re using  
 // a mutex to serialize the ipset calls.  
 pthread_mutex_t s_ipsetMutex;  
 // We&#39;re only adding a command/an element to to the set,  
 // so the restore line no. remains 0  
 #define IPSET_SESSION_LINE_NO 0  
 int  
 ipsetAdd(char *table, char *set_type, uint32_t interval)  
 {  
  int32_t ret = 0;  
  const struct ipset_type *type = NULL;  
  enum ipset_cmd cmd = IPSET_CMD_ADD;  
  struct ipset_session *session;  
  // debian-ipset calls are not thread-safe. We&#39;re adding  
  // a mutex to serialize the calls.  
  pthread_mutex_lock(&amp;amp;s_ipsetMutex);  
  ipset_load_types();  
  // Initialize an ipset session by allocating a session structure  
  // and filling out with the initialization data.  
  session = ipset_session_init(printf);  
  if (session == NULL)  
  {  
   printf(&quot;ipsetAdd: Cannot initialize ipset session for &quot;  
     &quot;set_type %s. aborting.\n&quot;, set_type);  
   ret = 1;  
  }  
  else  
  {  
   // Set session lineno to report parser errors correctly   
   ipset_session_lineno(session, IPSET_SESSION_LINE_NO);  
   // Parse string as a setname.  
   // The value is stored in the data blob of the session.  
   ret = ipset_parse_setname(session, IPSET_SETNAME, table);  
   if (ret == 0)  
   {  
    type = ipset_type_get(session, cmd);  
    if (!type)  
    {  
     printf(&quot;ipsetAdd: Failed to get the set type from Kernel &quot;  
       &quot;set_type=%s table=%s sess=%p cmd=%d\n&quot;, set_type, table,  
       session, cmd);  
     ret = 1;  
    }  
    else  
    {  
     // Parse string as a (multipart) element according to the settype.  
     // The value is stored in the data blob of the session.  
     ret = ipset_parse_elem(session, (enum ipset_opt)type-&amp;gt;last_elem_optional,  
                 set_type);  
     if (ret == 0)  
     {  
      // Put a given kind of data into the data blob and mark the  
      // option kind as already set in the blob.  
      ret = ipset_data_set(ipset_session_data(session), IPSET_OPT_TIMEOUT, &amp;amp;interval);  
      if (!ret)  
      {  
       // Execute a command  
       ret = ipset_cmd(session, cmd, IPSET_SESSION_LINE_NO);  
       if (ret)  
       {  
        printf(&quot;ipsetAdd: WARNING: Failed to execute &quot;  
          &quot;IPSET_CMD_ADD command. ipset exists? ret=%d set_type=%s table=%s\n&quot;,  
          ret, set_type, table);  
        // Not an error condition  
        ret = 0;  
       }  
      }  
      else  
      {  
       printf(&quot;ipsetAdd: Failed to set timeout option. &quot;  
         &quot;ret=%d set_type=%s table=%s\n&quot;, ret, set_type, table);  
      }  
     }  
     else  
     {  
      printf(&quot;ipsetAdd: Failed to parse element. &quot;  
        &quot;ret=%d set_type=%s table=%s\n&quot;, ret, set_type, table);  
     }  
    }  
   }  
   else  
   {  
    printf(&quot;ipsetAdd: Failed to parse setname. &quot;  
      &quot;ret=%d set_type=%s table=%s\n&quot;, ret, set_type, table);  
   }  
   // Finish the ipset session  
   if (ipset_session_fini(session) != 0)  
   {  
    printf(&quot;ipsetAdd: Failed to destroy ipset &quot;  
      &quot;session. ret=%d set_type=%s table=%s\n&quot;, ret, set_type,  
      table);  
   }  
  } // else of if (session == NULL)  
  pthread_mutex_unlock(&amp;amp;s_ipsetMutex);  
  return ret;  
 }  
&lt;/code&gt;&lt;/pre&gt;
</description><link>http://knownsandunknowns.blogspot.com/2014/04/using-ipset.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-1073819128368287409</guid><pubDate>Tue, 15 Apr 2014 23:07:00 +0000</pubDate><atom:updated>2014-04-15T16:22:59.225-07:00</atom:updated><title>Update Firefox on Ubuntu</title><description>For some strange reason, I couldn&#39;t open and see content of any of my yahoo mail using Firefox. I tried it on Chrome. It was working. So it must be something to do with Firefox + yahoo combination. Since I cannot fix yahoo from its setting (it doesn&#39;t even open), I in turn focused on fixing Firefox. Anyway I checked my add-ons and plug-ins and found nothing suspicious. So I decided to update my Firefox. I found the version from Help-&amp;gt;About Firefox. The version was 20 and there was NO update button/link despite of all the articles on the net saying so. Next I ran&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
sudo apt-get update
sudo apt-get --purge --reinstall install firefox
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Hoping the system will find the updates in the repositories and update Firefox for me. Nope. Firefox was not updated.

So I had to do it manually. Here are the steps:&lt;br/&gt;&lt;br/&gt;

1. Get a Linux 64-bit copy from &lt;a href=&quot;http://www.mozilla.org/en-US/firefox/all/?q=English%20%28US%29&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; and untar/uncompress it.

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
~/Downloads$ tar xvfj  firefox-28.0.tar.bz2
tar: Record size = 8 blocks
firefox/
firefox/libsoftokn3.so
firefox/chrome.manifest
firefox/mozilla-xremote-client
firefox/crashreporter.ini
firefox/libnspr4.so
firefox/updater
.
.
.
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
2. Backup your $HOME/.mozilla directory if you want to be careful.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ cd; cp .mozilla .mozilla.bak
&lt;/code&gt;&lt;/pre&gt;
3. Close all Firefox instances.&lt;br /&gt;
&lt;br /&gt;
4. Backup your firefox directory
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ sudo mv /usr/lib/firefox /usr/lib/firefox.bak
&lt;/code&gt;&lt;/pre&gt;
5. Move firefox directory you just uncompressed to /usr/lib
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ sudo mv ~/Downloads/firefox /usr/lib
&lt;/code&gt;&lt;/pre&gt;
6. Now give it a try by launching it from the launcher or command line.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ /usr/bin/firefox &amp;amp;
&lt;/code&gt;&lt;/pre&gt;
7. One more step, the firefox.png file seems to be missing from the latest Firefox 28 package. You will see a big red cross if this is not done. So to properly show firefox icon in your launcher. 
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$ sudo cp /usr/lib/firefox.backup/icons/mozicon128.png \ 
/usr/lib/firefox/icons
&lt;/code&gt;&lt;/pre&gt;
8. Try yahoo mail again. It works!&lt;br /&gt;
&lt;br /&gt;
9. Now you can delete all the backups if everything works as expected.
&lt;br /&gt;
&lt;br /&gt;
In a fairly good mode, so toss in a bonus tip - to open a file with the default application in command line:
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
xdg-open /usr/lib/firefox/mozicon128.png
&lt;/code&gt;&lt;/pre&gt;
</description><link>http://knownsandunknowns.blogspot.com/2014/04/update-firefox-on-ubuntu.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4370531360628656534</guid><pubDate>Sat, 15 Jun 2013 14:06:00 +0000</pubDate><atom:updated>2013-06-15T10:47:21.795-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MacOS</category><category domain="http://www.blogger.com/atom/ns#">ssh</category><category domain="http://www.blogger.com/atom/ns#">terminal</category><title>Frozen MacOS terminal due ssh session timeout</title><description>To get out of a frozen terminal due to ssh timeout. Type the following keys:&lt;br /&gt;
&lt;br /&gt;
enter (return key) ~.&lt;br /&gt;
&lt;br /&gt;
Add the following to your .ssh/config file. It sends a signal to the server every 240 seconds to keep the session.&lt;br /&gt;
&lt;br /&gt;
Host *&lt;br /&gt;
&amp;nbsp; ServerAliveInterval 240&lt;br /&gt;
&lt;br /&gt;
Reference: http://www.metachunk.com/blog/dealing-osx-terminal-ssh-timeouts-0</description><link>http://knownsandunknowns.blogspot.com/2013/06/frozen-macos-terminal-due-ssh-session.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-3462423388420576214</guid><pubDate>Mon, 30 Jul 2012 21:35:00 +0000</pubDate><atom:updated>2012-07-30T14:37:48.840-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">matchit</category><category domain="http://www.blogger.com/atom/ns#">vi</category><category domain="http://www.blogger.com/atom/ns#">vim</category><title>vim 7.x and matchit plugin</title><description>For a few months I have been trying to make my vim (7.2.330) in Ubuntu 10.04 work with matchit plugin. But it never wanted to cooperate. The matchit plugin works perfectly with my vim 6.4.6 by simply downloading/unzipping the match.zip from &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=39&quot;&gt;here&lt;/a&gt; and adding the following line to ~/.vimrc file.&lt;br /&gt;
&lt;br /&gt;
:source {path_to_matchit_plugin}/matchit.vim&lt;br /&gt;
&lt;br /&gt;
But for vim 7.x, the following line has be to added to ~/.vimrc as well:&lt;br /&gt;
&lt;br /&gt;
:filetype plugin on</description><link>http://knownsandunknowns.blogspot.com/2012/07/vim-7x-and-matchit-plug.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4704234125360634697</guid><pubDate>Fri, 24 Feb 2012 20:27:00 +0000</pubDate><atom:updated>2012-02-24T12:29:34.334-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">website</category><title>Mapping Your Domain Name to Work with Blogger</title><description>From GoDaddy support center: &lt;a href=&quot;http://help.godaddy.com/article/5112#parking%20&quot;&gt;http://help.godaddy.com/article/5112#parking &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You can establish a more professional identity for your Blogger® blog  by configuring it to point to one of the domain names you registered  through us. Instead of entering your Blogger URL to view your latest  blog post, visitors enter your domain name&#39;s URL. For example, by  mapping your coolexample.blogspot.com blog to your www.coolexample.com  domain name, visitors focus solely on your domain name.&lt;br /&gt;
To point your Blogger blog to your domain name, you set up domain  name mapping, which configures your blog settings and domain name. You  update your settings in your Blogger account and our Domain Manager:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Park the domain name you want to use with your Blogger account on our parked nameservers.&lt;/li&gt;
&lt;li&gt;Edit the &lt;b&gt;www&lt;/b&gt; CNAME record for the domain name you  want to use with your Blogger account. This update tells the Web browser  to open your Blogger blog when visitors enter your domain name&#39;s URL in  the browser address bar.&lt;/li&gt;
&lt;li&gt;Forward your domain name to use &lt;b&gt;www&lt;/b&gt;. This step ensures your Blogger blog displays for visitors who go to your domain name with or without the &lt;b&gt;www&lt;/b&gt; prefix. For example, it displays for visitors who entered both www.coolexample.com and coolexample.com.&lt;/li&gt;
&lt;li&gt;Configure your Blogger account to use your domain name.&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;many-open all-closed&quot;&gt;&lt;h3 class=&quot;display&quot; id=&quot;__display-auto-increment:0&quot; title=&quot;parking&quot;&gt;&lt;a href=&quot;http://help.godaddy.com/article/5112#parking&quot;&gt;To Park Your Domain Name&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;stretcher&quot; style=&quot;overflow: visible;&quot;&gt;&lt;div class=&quot;stretcher-container&quot;&gt;&lt;ol&gt;&lt;li&gt;Log in to your &lt;a href=&quot;http://mya.godaddy.com/default.aspx?prog_id=GoDaddy&quot; target=&quot;_blank&quot;&gt;Account Manager&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Next to &lt;b&gt;Domains&lt;/b&gt;, click &lt;b&gt;Launch&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Select the domain name you want to use with your Blogger account, and then from the &lt;b&gt;Nameservers&lt;/b&gt;, select &lt;b&gt;Set Nameservers&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;b&gt;I want to park my domains&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;OK&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;OK&lt;/b&gt; again.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 class=&quot;display&quot; id=&quot;__display-auto-increment:1&quot; title=&quot;editing&quot;&gt;&lt;a href=&quot;http://help.godaddy.com/article/5112#editing&quot;&gt;To Edit Your CNAME Record&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;stretcher&quot; style=&quot;overflow: visible;&quot;&gt;&lt;div class=&quot;stretcher-container&quot;&gt;&lt;ol&gt;&lt;li&gt;Log in to your &lt;a href=&quot;http://mya.godaddy.com/default.aspx?prog_id=GoDaddy&quot; target=&quot;_blank&quot;&gt;Account Manager&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Next to &lt;b&gt;Domains&lt;/b&gt;, click &lt;b&gt;Launch&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;From the &lt;b&gt;Tools&lt;/b&gt; menu, select &lt;b&gt;DNS Manager&lt;/b&gt;. The DNS Dashboard displays.&lt;/li&gt;
&lt;li&gt;For the domain name you want to use with your Blogger account, click &lt;b&gt;Edit Zone&lt;/b&gt;. The Zone File Editor displays.&lt;/li&gt;
&lt;li&gt;In the &lt;b&gt;CNAME (Alias)&lt;/b&gt; section, click the &lt;b&gt;www&lt;/b&gt; record.&lt;/li&gt;
&lt;li&gt;In the &lt;b&gt;Points To&lt;/b&gt; field, type &lt;b&gt;ghs.google.com&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;Save Zone File&lt;/b&gt;, and then click &lt;b&gt;OK&lt;/b&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 class=&quot;display&quot; id=&quot;__display-auto-increment:2&quot; title=&quot;forwarding&quot;&gt;&lt;a href=&quot;http://help.godaddy.com/article/5112#forwarding&quot;&gt;To Forward Your Domain Name&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;stretcher&quot; style=&quot;overflow: visible;&quot;&gt;&lt;div class=&quot;stretcher-container&quot;&gt;&lt;ol&gt;&lt;li&gt;Go to &lt;a href=&quot;http://support.google.com/blogger/bin/static.py?hl=en&amp;amp;ts=1233381&amp;amp;page=ts.cs&quot;&gt;support.google.com&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;Host my blog on a URL that I already own&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Follow the listed instructions.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;h3 class=&quot;display&quot; id=&quot;__display-auto-increment:3&quot; title=&quot;configuring&quot;&gt;&lt;a href=&quot;http://help.godaddy.com/article/5112#configuring&quot;&gt;To Configure Your Blogger Account&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;stretcher&quot; style=&quot;overflow: visible;&quot;&gt;&lt;div class=&quot;stretcher-container&quot;&gt;&lt;ol&gt;&lt;li&gt;Log in to your Blogger account.&lt;/li&gt;
&lt;li&gt;From the &lt;b&gt;Settings&lt;/b&gt; tab, select &lt;b&gt;Publishing&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;Custom Domain&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;b&gt;Buy a domain for your blog&lt;/b&gt; section, click &lt;b&gt;Switch to advanced settings&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;b&gt;Your Domain&lt;/b&gt; field, enter your domain name. For example, enter www.coolexample.com.&lt;/li&gt;
&lt;li&gt;To specify another location in which to look for files, in the &lt;b&gt;Use a missing files host?&lt;/b&gt; section, select &lt;b&gt;Yes&lt;/b&gt; and enter the path. If not, select &lt;b&gt;No&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;In the &lt;b&gt;Word Verification&lt;/b&gt; field, enter the characters as they display in the image above the field.&lt;/li&gt;
&lt;li&gt;Click &lt;b&gt;Save Settings&lt;/b&gt;.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;Any DNS changes you make can take up to 48 hours to reflect on the Internet.&lt;br /&gt;
&lt;div class=&quot;note&quot;&gt;&lt;b&gt;NOTE:&lt;/b&gt; As a courtesy, we provide  information about how to use certain third-party products, but we do not  endorse or directly support third-party products and we are not  responsible for the functions or reliability of such products. Blogger®  is a registered trademark of Google, Inc. All rights reserved.&lt;/div&gt;</description><link>http://knownsandunknowns.blogspot.com/2012/02/mapping-your-domain-name-through-google.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-2402483419595070229</guid><pubDate>Tue, 17 Jan 2012 19:24:00 +0000</pubDate><atom:updated>2012-01-17T11:24:10.341-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><title>Find a process and kill it in a script in Linux</title><description>ps -ef | grep process_name | awk &#39;{ print $2; }&#39;| xargs kill -9</description><link>http://knownsandunknowns.blogspot.com/2012/01/find-process-and-kill-it-in-script-in.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4249971984014843540</guid><pubDate>Wed, 20 Apr 2011 04:22:00 +0000</pubDate><atom:updated>2011-05-15T20:35:49.177-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computer science</category><title>Computer Science Terms</title><description>Algorithms: Are well-defined procedures for solving problems.&lt;br /&gt;
&lt;br /&gt;
Data Structure: Is a particular way of storing and organizing data in a computer so that it can be used efficiently. &lt;br /&gt;
&lt;br /&gt;
Dangling Pointers: Pointers that point to invalid addresses. Some examples of programming errors that can lead to dangling pointers include casting arbitrary integers to pointers, adjusting pointers beyond the bounds of arrays, and deallocating storage that one or more pointers still reference.</description><link>http://knownsandunknowns.blogspot.com/2011/04/computer-science-terms.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-2883475964597471894</guid><pubDate>Thu, 10 Mar 2011 20:30:00 +0000</pubDate><atom:updated>2013-06-15T07:11:43.679-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computer science</category><title>Hash Table or Hash Map</title><description>In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys (e.g., a person&#39;s name), to their associated values (e.g., their telephone number). Thus, a hash table implements an associative array. The hash function is used to transform the key into the index (the hash) of an array element (the slot or bucket) where the corresponding value is to be sought.&lt;br /&gt;
&lt;br /&gt;
Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added to the table after creation). Most hash table designs assume that hash collisions—the situation where different keys happen to have the same hash value—are normal occurrences and must be accommodated in some way.&lt;br /&gt;
&lt;br /&gt;
In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is independent of the number of elements stored in the table. Many hash table designs also allow arbitrary insertions and deletions of key-value pairs, at constant average (indeed, amortized[1]) cost per operation.[2][3]&lt;br /&gt;
&lt;br /&gt;
In many situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.&lt;br /&gt;
&lt;br /&gt;
Credit for above paragraphs: http://en.wikipedia.org/wiki/Hash_table </description><link>http://knownsandunknowns.blogspot.com/2011/03/hash-table-or-hash-map.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-8926324997438516456</guid><pubDate>Mon, 22 Nov 2010 19:52:00 +0000</pubDate><atom:updated>2010-11-22T11:54:06.435-08:00</atom:updated><title>Building thrift 0.5.0 on CentOS 5.3</title><description>You will need php 5.2 or above to successfully build thrift 0.5.0 or you will see the following error:&lt;br /&gt;
&lt;br /&gt;
&#39;zend_std_get_constructor&#39; was not declared in this scope.&lt;br /&gt;
&lt;br /&gt;
Download php 5.2.14 source from &lt;a href=&quot;http://us.php.net/get/php-5.2.14.tar.gz/from/a/mirror&quot;&gt;here&lt;/a&gt; and go through the usual &quot;configure-&gt;make-&gt;sudo make install&quot; cycle.</description><link>http://knownsandunknowns.blogspot.com/2010/11/building-thrift-050-on-centos-53.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-6396017101942336011</guid><pubDate>Fri, 19 Nov 2010 18:27:00 +0000</pubDate><atom:updated>2010-11-19T10:27:21.527-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">chinese</category><category domain="http://www.blogger.com/atom/ns#">firefox</category><category domain="http://www.blogger.com/atom/ns#">font</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Display Chinese in Firefox on CentOS</title><description>1. sudo yum groupinstall chinese-support&lt;br /&gt;
2. Restart firefox</description><link>http://knownsandunknowns.blogspot.com/2010/11/display-chinese-in-firefox-on-centos.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4641987537606017127</guid><pubDate>Thu, 04 Nov 2010 19:28:00 +0000</pubDate><atom:updated>2010-11-04T12:29:13.876-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CentOS</category><category domain="http://www.blogger.com/atom/ns#">installation</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Ultra 45</category><category domain="http://www.blogger.com/atom/ns#">usb</category><title>Installing CentOS 4.4 using USB</title><description>Ok, I know this is an old version. But if for some reasons, your environment still calls for this kind of system.&lt;br /&gt;
&lt;br /&gt;
1. Download the following from http://vault.centos.org/4.4/isos/i386&lt;br /&gt;
&lt;a href=&quot;http://vault.centos.org/4.4/isos/i386/CentOS-4.4-i386-bin1of4.iso&quot;&gt;CentOS-4.4-i386-bin1of4.iso&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://vault.centos.org/4.4/isos/i386/CentOS-4.4-i386-bin2of4.iso&quot;&gt;CentOS-4.4-i386-bin2of4.iso&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://vault.centos.org/4.4/isos/i386/CentOS-4.4-i386-bin3of4.iso&quot;&gt;CentOS-4.4-i386-bin3of4.iso&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://vault.centos.org/4.4/isos/i386/CentOS-4.4-i386-bin4of4.iso&quot;&gt;CentOS-4.4-i386-bin4of4.iso&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Windows&lt;br /&gt;
&lt;br /&gt;
2. Use MagicDisc to mount the the ISOes to different drives. Open the the drives and copy all the files to a directory. Overwrite the files that have the same names.&lt;br /&gt;
Linux&lt;br /&gt;
2. Mount the iso&lt;br /&gt;
# mkdir /mnt/iso&lt;br /&gt;
# mount -o loop disk1.iso /mnt/iso&lt;br /&gt;
Copy all the files to a directory, e.g. centos44&lt;br /&gt;
# cp -r /mnt/iso/* centos44&lt;br /&gt;
Do the above for all the iso files.&lt;br /&gt;
&lt;br /&gt;
3. Windows: Use MagicISO to write the files to an ISO; Linux: &lt;br /&gt;
# mkisofs -o centos44-i386.iso ./centos44&lt;br /&gt;
&lt;br /&gt;
4. Use UNetbootin (http://unetbootin.sourceforge.net) to write the ISO to your USB drive&lt;br /&gt;
&lt;br /&gt;
5. Boot from USB in your system that is to be installed. Select HTTP installation.&lt;br /&gt;
Site: vault.centos.org&lt;br /&gt;
Direcotry: 4.4/os/i386&lt;br /&gt;
&lt;br /&gt;
The reason why we have to do this instead of using the CentOS-4.4.ServerCD-i386.iso file is that the &lt;br /&gt;
Server ISO does not match with the installation directory structure. The installation will not start.</description><link>http://knownsandunknowns.blogspot.com/2010/11/installing-centos-44-using-usb.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4497374233165503077</guid><pubDate>Fri, 29 Oct 2010 21:33:00 +0000</pubDate><atom:updated>2010-10-29T14:33:40.123-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">Scripting</category><category domain="http://www.blogger.com/atom/ns#">unix</category><title>Find out gcc version in a script</title><description>user@local$ gcc -v 2&gt;&amp;1 | tail -1 | awk &#39;{print $3}&#39;&lt;br /&gt;
4.4.3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Only want the major version number:&lt;br /&gt;
&lt;br /&gt;
gcc -v 2&gt;&amp;1 | tail -1 | awk &#39;{print $3}&#39;|cut -d. -f1&lt;br /&gt;
4</description><link>http://knownsandunknowns.blogspot.com/2010/10/find-out-gcc-version-in-script.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-6257373028629822260</guid><pubDate>Thu, 16 Sep 2010 18:58:00 +0000</pubDate><atom:updated>2011-03-31T16:41:02.041-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">build</category><category domain="http://www.blogger.com/atom/ns#">CentOS</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">log4j</category><category domain="http://www.blogger.com/atom/ns#">Open Source</category><category domain="http://www.blogger.com/atom/ns#">Scribe</category><title>log4j and Scribe</title><description>Well I thought it should be fairly easy. But it turned out it&#39;s not that straightforward especially for a Java newbie like me. Basically we need to make a log4j appender for Scribe. Fortunately it&#39;s available from &lt;a href=&quot;http://github.com/lenn0x/Scribe-log4j-Appender&quot;&gt;http://github.com/lenn0x/Scribe-log4j-Appender&lt;/a&gt;. The package contains scribelog4j.jar already. Just in case you want to build it yourself or change the referencing libraries, here are the instructions. The following were tested on CentOS 5.3 64-bit.&lt;br /&gt;
&lt;br /&gt;
1. Download and extract log4j from&amp;nbsp; &lt;a href=&quot;http://logging.apache.org/log4j/1.2/download.html&quot;&gt;http://logging.apache.org/log4j/1.2/download.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
2. Download and extract Scribe 2.2 and Thrift from &lt;a href=&quot;http://github.com/facebook/scribe/downloads&quot;&gt;http://github.com/facebook/scribe/downloads&lt;/a&gt; and &lt;a href=&quot;http://incubator.apache.org/thrift/download&quot;&gt;http://incubator.apache.org/thrift/download &lt;/a&gt;(the current version is 0.5.0, I am using 0.2.0 in this example.)&lt;br /&gt;
&lt;br /&gt;
Build Thrift and install. Please refer to Step 14 in &lt;a href=&quot;http://knownsandunknowns.blogspot.com/2010/08/running-scribe-with-hdfs-support-on.html&quot;&gt;Installing &amp;amp; Running Scribe with HDFS support on CentOS&lt;/a&gt; article.&lt;br /&gt;
&lt;br /&gt;
3. Download and extract slf4j (Simple Logging Facade for Java) from &lt;a href=&quot;http://www.slf4j.org/download.html&quot;&gt;http://www.slf4j.org/download.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
4. Install latest ant if you haven&#39;t. See the previous post: &lt;a href=&quot;http://knownsandunknowns.blogspot.com/2010/09/installing-latest-ant-in-centos.html&quot;&gt;Installing Latest Ant on CentOS&lt;/a&gt;. Thrift jar cannot be built using ant 1.6.5 from original CentOS repository.&lt;br /&gt;
&lt;code&gt;&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;
5. Build libthrift.jar. From top Thrift directory:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/thrift-0.2.0] cd lib/java&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/thrift-0.2.0/lib/java] ant&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
You should see libthrift.jar in the current directory.&lt;br /&gt;
&lt;br /&gt;
6. Build libfb303.jar. From top Thrift directory:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/thrift-0.2.0] cd contrib/fb303/java&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Edit build.xml file.&lt;br /&gt;
&lt;br /&gt;
Find &quot;&amp;lt;classpath&amp;gt;&quot; and change the value of &quot;pathelement location&quot; to where your libthrift.jar is.&lt;br /&gt;
&lt;br /&gt;
My thrift is in $HOME/pkgs/thrift-0.2.0 directory. So I add a new property name on the top.&lt;br /&gt;
&lt;code&gt;&amp;lt;property name=&quot;pkgs.dir&quot; value=&quot;${user.home}/pkgs&quot;/&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Also slf4j&#39;s api jar has to be added to classpath as well.&lt;br /&gt;
&lt;br /&gt;
The pathelement location lines should look like the following:&lt;br /&gt;
&lt;code&gt;&amp;lt;pathelement location=&quot;${pkgs.dir}/thrift-0.2.0/lib/java/libthrift.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/slf4j-1.6.1/slf4j-api-1.6.1.jar&quot;/&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Remove FacebookBase.java file. This has to be done or you will get &quot;getStatus() in com.facebook.fb303.FacebookBase cannot implement getStatus() in com.facebook.fb303.FacebookService.Iface; attempting to use incompatible return type&quot; error.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/thrift-0.2.0/contrib/fb303/java] rm FacebookBase.java &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Run ant.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/thrift-0.2.0/contrib/fb303/java] ant&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
You should find libfb303.jar in build/lib directory&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/thrift-0.2.0/contrib/fb303/java] ll build/lib/&lt;br /&gt;
total 176&lt;br /&gt;
drwxr-xr-x 2 user user   4096 Sep 16 12:09 .&lt;br /&gt;
drwxr-xr-x 4 user user   4096 Sep 16 11:45 ..&lt;br /&gt;
-rw-r--r-- 1 user user 165162 Sep 16 12:09 libfb303.jar&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
7. Build scribe.jar. From top level scribe directory:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost::~/pkgs/scribe] cd if&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Edit scribe.thrift&lt;br /&gt;
Add the following line in the file.&lt;br /&gt;
&lt;code&gt;namespace java scribe&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Copy fb303 thrift directory here.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/scribe/if] cp -r ~/pkgs/thrift-0.2.0/contrib/fb303/ . &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
And copy fb303&#39;s build.xml here as well&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/scribe/if] cp ~/pkgs/thrift-0.2.0/contrib/fb303/java/build.xml . &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Edit build.xml to build scribe.jar. The file will look like the following. magenta text indicates the modifications for building scribe.jar.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&amp;lt;!--&lt;br /&gt;
Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
or more contributor license agreements. See the NOTICE file&lt;br /&gt;
distributed with this work for additional information&lt;br /&gt;
regarding copyright ownership. The ASF licenses this file&lt;br /&gt;
to you under the Apache License, Version 2.0 (the&lt;br /&gt;
&quot;License&quot;); you may not use this file except in compliance&lt;br /&gt;
with the License. You may obtain a copy of the License at&lt;br /&gt;
&lt;br /&gt;
http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
&lt;br /&gt;
Unless required by applicable law or agreed to in writing,&lt;br /&gt;
software distributed under the License is distributed on an&lt;br /&gt;
&quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
KIND, either express or implied. See the License for the&lt;br /&gt;
specific language governing permissions and limitations&lt;br /&gt;
under the License.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;project name=&quot;scribe&quot; default=&quot;dist&quot; basedir=&quot;..&quot;&amp;gt;&lt;br /&gt;
&amp;lt;!-- project wide settings. All directories relative to basedir --&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;property name=&quot;src.dir&quot; value=&quot;if&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;property name=&quot;if.dir&quot; value=&quot;if&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;thrift_home&quot; value=&quot;/usr/local&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;pkgs.dir&quot; value=&quot;${user.home}/pkgs&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;!-- temp build directories --&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build.dir&quot; value=&quot;${src.dir}/build&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build.classes.dir&quot; value=&quot;${build.dir}/classes&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build.lib.dir&quot; value=&quot;${build.dir}/lib&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- final distribution directories --&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;dist.dir&quot; value=&quot;/usr/local&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;dist.lib.dir&quot; value=&quot;${dist.dir}/lib&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- make temporary and distribution directories --&amp;gt;&lt;br /&gt;
&amp;lt;target name=&quot;prepare&quot;&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${build.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${build.classes.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${build.lib.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${dist.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${dist.lib.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- generate scribe thrift code --&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;target name=&quot;scribebuild&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;echo&amp;gt;generating thrift scribe files&amp;lt;/echo&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;exec executable=&quot;${thrift_home}/bin/thrift&quot;  failonerror=&quot;true&quot;&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;arg line=&quot;--gen java -o ${src.dir} ${src.dir}/../if/scribe.thrift&quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;/exec&amp;gt;&lt;br /&gt;
&amp;lt;move todir=&quot;${src.dir}&quot;&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;fileset dir=&quot;${src.dir}/gen-java/scribe&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;include name=&quot;**/*.java&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/fileset&amp;gt;&lt;br /&gt;
&amp;lt;/move&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- compile the base and thrift generated code and jar them --&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;target name=&quot;dist&quot; depends=&quot;prepare,scribebuild&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;echo&amp;gt;Building scribe.jar .... &amp;lt;/echo&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;javac srcdir=&quot;${src.dir}&quot; destdir=&quot;${build.classes.dir}&quot; debug=&quot;on&quot;&amp;gt;&lt;br /&gt;
&amp;lt;classpath&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;pathelement location=&quot;${pkgs.dir}/thrift-0.4.0/lib/java/libthrift.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/slf4j-1.6.1/slf4j-api-1.6.1.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/thrift-0.4.0/contrib/fb303/java/build/lib/lib&lt;/span&gt;fb303.jar&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/classpath&amp;gt;&lt;br /&gt;
&amp;lt;include name=&quot;*.java&quot;/&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;include name=&quot;${build.dir}/scribe&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;/javac&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;jar jarfile=&quot;${build.lib.dir}/scribe.jar&quot; basedir=&quot;${build.classes.dir}&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;/jar&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- copy the build jar to the distribution library directory --&amp;gt;&lt;br /&gt;
&amp;lt;target name=&quot;install&quot; depends=&quot;dist&quot;&amp;gt;&lt;br /&gt;
&amp;lt;copy todir=&quot;${dist.lib.dir}&quot;&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&amp;lt;fileset dir=&quot;${build.lib.dir}&quot; includes=&quot;scribe.jar&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;/copy&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;clean&quot;&amp;gt;&lt;br /&gt;
&amp;lt;echo&amp;gt;Cleaning old stuff .... &amp;lt;/echo&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;${build.dir}/classes/com&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;${build.dir}/lib&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;${build.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&amp;lt;/project&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Run ant.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/scribe/if] ant &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
You will see scribe.jar in build/lib directory.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/scribe/if] ll build/lib/&lt;br /&gt;
total 36&lt;br /&gt;
drwxr-xr-x 2 user user  4096 Sep 16 12:55 .&lt;br /&gt;
drwxr-xr-x 4 user user  4096 Sep 16 12:55 ..&lt;br /&gt;
-rw-r--r-- 1 user user 27002 Sep 16 12:58 scribe.jar&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
8. Build scribelog4j.jar&lt;br /&gt;
&lt;br /&gt;
First Get Scribe-log4j-Appender using git.&lt;br /&gt;
&lt;br /&gt;
If git is not installed.&lt;br /&gt;
&lt;code&gt;&lt;code&gt;yum -y install git&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Get the code.&lt;br /&gt;
&lt;code&gt;&lt;code&gt;git clone http://github.com/lenn0x/Scribe-log4j-Appender.git&lt;/code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The code will be in Scribe-log4j-Appender directory. Change to the directory.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/Scribe-log4j-Appender] cd src/java/org/apache/log4j&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Copy scribe&#39;s build.xml here.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/Scribe-log4j-Appender/src/java/org/apache/log4j] cp ~/pkgs/scribe/if/build.xml .&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Edit build.xml and it should look like the following. Adjust the magenta part if needed.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&amp;lt;project name=&quot;scribelog4j&quot; default=&quot;dist&quot; basedir=&quot;..&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- project wide settings. All directories relative to basedir --&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;src.dir&quot; value=&quot;&lt;span style=&quot;color: magenta;&quot;&gt;log4j/scribe&lt;/span&gt;&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;if.dir&quot; value=&quot;if&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;thrift_home&quot; value=&quot;/usr/local&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;pkgs.dir&quot; value=&quot;${user.home}/pkgs&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- temp build directories --&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build.dir&quot; value=&quot;${src.dir}/build&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build.classes.dir&quot; value=&quot;${build.dir}/classes&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;build.lib.dir&quot; value=&quot;${build.dir}/lib&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- final distribution directories --&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;dist.dir&quot; value=&quot;/usr/local&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;dist.lib.dir&quot; value=&quot;${dist.dir}/lib&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- make temporary and distribution directories --&amp;gt;&lt;br /&gt;
&amp;lt;target name=&quot;prepare&quot;&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${build.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${build.classes.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${build.lib.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${dist.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;mkdir dir=&quot;${dist.lib.dir}&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- compile the base and thrift generated code and jar them --&amp;gt;&lt;br /&gt;
&amp;lt;target name=&quot;dist&quot; depends=&quot;prepare&quot;&amp;gt;&lt;br /&gt;
&amp;lt;echo&amp;gt;Building scribelog4j.jar .... &amp;lt;/echo&amp;gt;&lt;br /&gt;
&amp;lt;javac srcdir=&quot;${src.dir}&quot; destdir=&quot;${build.classes.dir}&quot; debug=&quot;on&quot;&amp;gt;&lt;br /&gt;
&amp;lt;classpath&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/thrift-0.2.0/lib/java/libthrift.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/slf4j-1.6.1/slf4j-api-1.6.1.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/thrift-0.2.0/contrib/fb303/java/build/lib/libfb303.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;pathelement location=&quot;${pkgs.dir}/scribe/if/build/lib/scribe.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/classpath&amp;gt;&lt;br /&gt;
&amp;lt;include name=&quot;*.java&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;include name=&quot;${build.dir}/scribe&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/javac&amp;gt;&lt;br /&gt;
&amp;lt;jar jarfile=&quot;${build.lib.dir}/scribelog4j.jar&quot; basedir=&quot;${build.classes.dir}&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/jar&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- copy the build jar to the distribution library directory --&amp;gt;&lt;br /&gt;
&amp;lt;target name=&quot;install&quot; depends=&quot;dist&quot;&amp;gt;&lt;br /&gt;
&amp;lt;copy todir=&quot;${dist.lib.dir}&quot;&amp;gt;&lt;br /&gt;
&amp;lt;fileset dir=&quot;${build.lib.dir}&quot; includes=&quot;scribelog4j.jar&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/copy&amp;gt;&lt;br /&gt;
&amp;lt;/target&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;target name=&quot;clean&quot;&amp;gt;&lt;br /&gt;
&amp;lt;echo&amp;gt;Cleaning old stuff .... &amp;lt;/echo&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;${build.dir}/classes/com&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;${build.dir}/lib&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;delete dir=&quot;${build.dir}&quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/target&amp;gt;&lt;br /&gt;
&amp;lt;/project&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Run ant.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/pkgs/Scribe-log4j-Appender/src/java/org/apache/log4j] ant &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
You should get scribelog4j.jar in the current directory.&lt;br /&gt;
&lt;br /&gt;
9. Write and run a test program&lt;br /&gt;
&lt;br /&gt;
Here is the test program called scribelog4j_test.java&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;public class scribelog4j_test {&lt;br /&gt;
    private static Logger logger = Logger.getLogger(scribelog4j_test.class);&lt;br /&gt;
    public static void main(String[] args) {&lt;br /&gt;
        long time = System.currentTimeMillis();&lt;br /&gt;
        logger.info(&quot;main method called..&quot;);&lt;br /&gt;
        logger.info(&quot;another informative message&quot;);&lt;br /&gt;
        logger.warn(&quot;This one is a warning!&quot;);&lt;br /&gt;
        logger.log(Level.TRACE,&lt;br /&gt;
                &quot;And a trace message using log() method.&quot;);&lt;br /&gt;
        long logTime = System.currentTimeMillis() - time;&lt;br /&gt;
&lt;br /&gt;
        logger.debug(&quot;Time taken to log the previous messages: &quot;&lt;br /&gt;
                + logTime + &quot; msecs&quot;);&lt;br /&gt;
&lt;br /&gt;
        // Exception logging example:&lt;br /&gt;
        try{&lt;br /&gt;
            String subs = &quot;hello&quot;.substring(6);&lt;br /&gt;
        }catch (Exception e){&lt;br /&gt;
            logger.error(&quot;Error in main() method:&quot;, e);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Create a file called log4j.properties in the current directory. It should look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;log4j.rootLogger=debug, stdout, R, scribe&lt;br /&gt;
&lt;br /&gt;
log4j.appender.stdout=org.apache.log4j.ConsoleAppender&lt;br /&gt;
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
&lt;br /&gt;
# Pattern to output the caller&#39;s file name and line number.&lt;br /&gt;
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n&lt;br /&gt;
&lt;br /&gt;
log4j.appender.R=org.apache.log4j.RollingFileAppender&lt;br /&gt;
log4j.appender.R.File=example.log&lt;br /&gt;
&lt;br /&gt;
log4j.appender.R.MaxFileSize=100KB&lt;br /&gt;
# Keep one backup file&lt;br /&gt;
log4j.appender.R.MaxBackupIndex=1&lt;br /&gt;
&lt;br /&gt;
log4j.appender.R.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Add this to your log4j.properties&lt;br /&gt;
#&lt;br /&gt;
log4j.appender.scribe=org.apache.log4j.scribe.ScribeAppender&lt;br /&gt;
log4j.appender.scribe.scribe_category=MyScribeCategoryName&lt;br /&gt;
log4j.appender.scribe.scribe_host=127.0.0.1&lt;br /&gt;
log4j.appender.scribe.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
log4j.appender.scribe.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
For convenience, copy all the necessary jars to a directory called lib.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost:~/proj/scribe_log4j] ls lib&lt;br /&gt;
libfb303.jar   log4j-1.2.16.jar  scribelog4j.jar      slf4j-log4j12-1.6.1.jar&lt;br /&gt;
libthrift.jar  scribe.jar        slf4j-api-1.6.1.jar&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To build it:&lt;br /&gt;
&lt;code&gt;/usr/bin/javac -classpath .:lib/scribelog4j.jar:lib/log4j-1.2.16.jar  ./scribelog4j_test.java&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To run it:&lt;br /&gt;
&lt;br /&gt;
Start the Scribe server in a new terminal.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/scribe/src] scribed ../examples/example1.conf &lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
In the original terminal, run scribelog4j_test program.&lt;br /&gt;
&lt;code&gt;[user@localhost:~/proj/scribe_log4j] /usr/bin/java -classpath .:lib/log4j-1.2.16.jar:lib/scribelog4j.jar::lib/libthrift.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4j12-1.6.1.jar:lib/scribe.jar:lib/libfb303.jar scribelog4j_test&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
You should find the log file in /tmp/scribetest directory.</description><link>http://knownsandunknowns.blogspot.com/2010/09/log4j-and-scribe.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4176874758203604881</guid><pubDate>Wed, 15 Sep 2010 21:57:00 +0000</pubDate><atom:updated>2010-09-16T11:36:31.427-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ant</category><category domain="http://www.blogger.com/atom/ns#">build</category><category domain="http://www.blogger.com/atom/ns#">CentOS</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">jpackage</category><category domain="http://www.blogger.com/atom/ns#">tools</category><title>Installing Latest Ant on CentOS</title><description>To install the latest version of ant (ant-1.7.1-7.jpp5.noarch) from JPackage instead of the version provided by yum (ant-1.6.5-2jpp.2.x86_64). Here are the steps on CentOS 5.3 64-bit system.&lt;br /&gt;
&lt;br /&gt;
1. Download and install JPackage rpm (jpackage-release-5-4.jpp5.noarch.rpm) from &lt;a href=&quot;http://jpackage.org/browser/rpm.php?jppversion=5.0&amp;amp;id=8559.&quot;&gt;JPackage site&lt;/a&gt;. This will add jpackage.repo to your /etc/yum.repos.d directory.&lt;br /&gt;
&lt;br /&gt;
2. Use yum to search &quot;ant.&quot;, you will see ant.noarch provided by JPackage repo in the list. But right now if you try to install it, the following error would occur.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;Error: Missing Dependency: /usr/bin/rebuild-security-providers is needed 
by package java-1.4.2-gcj-compat&lt;/pre&gt;&lt;br /&gt;
Check which package is providing rebuild-security-providers. &lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;pre&gt;rpm -q --whatprovides /usr/bin/rebuild-security-providers
jpackage-utils-1.7.3-1jpp.2.el5&lt;/pre&gt;&lt;br /&gt;
jpackage-utils has been installed in the system.&lt;br /&gt;
&lt;br /&gt;
Looks like this RedHat version of jpackage-utils doesn&#39;t work with this latest version of ant from JPackage.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
a. Uninstall jpackage-utils without uninstalling all the dependencies.&lt;br /&gt;
[user@localhost] sudo rpm -e --nodeps jpackage-utils-1.7.3-1jpp.2.el5&lt;br /&gt;
&lt;br /&gt;
b. Install jpackage-utils (jpackage-utils-5.0.0-2.jpp5.noarch.rpm) from &lt;a href=&quot;http://www.jpackage.org/browser/rpm.php?jppversion=5.0&amp;amp;id=8164&quot;&gt;JPackage. &lt;/a&gt;&lt;br /&gt;
[user@localhost] sudo rpm -Uvh jpackage-utils-5.0.0-2.jpp5.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
c. Install ant.noarch&lt;br /&gt;
[user@localhost] sudo yum install ant.noarch</description><link>http://knownsandunknowns.blogspot.com/2010/09/installing-latest-ant-in-centos.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-7503600760453925798</guid><pubDate>Tue, 31 Aug 2010 20:24:00 +0000</pubDate><atom:updated>2014-07-01T17:08:18.057-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">backend</category><category domain="http://www.blogger.com/atom/ns#">CentOS</category><category domain="http://www.blogger.com/atom/ns#">Hadoop</category><category domain="http://www.blogger.com/atom/ns#">HDFS</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Open Source</category><category domain="http://www.blogger.com/atom/ns#">Scribe</category><title>Installing &amp; Running Scribe with HDFS support on CentOS</title><description>Have being working on Scribe for our logging for a while. Finally feel like writing something about it. The main trigger came from a request to support HDFS. Since I always like to tackle open source project&#39;s incompatibilities on different environments, I made this challenge the highest priority (although my boss probably doesn&#39;t think so...)&lt;br /&gt;
&lt;br /&gt;
Installing Scribe on CentOS 5.3 64-bit&lt;br /&gt;
&lt;br /&gt;
1. Java SE Development Kit (JDK) 6 latest update - &lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/index.html&quot;&gt;http://www.oracle.com/technetwork/java/javase/downloads/index.html&lt;/a&gt;. I used update 20. The java directory is: /usr/java/jdk1.6.0_20.&lt;br /&gt;
&lt;br /&gt;
2. ruby-1.8.5-5.el5_4.8 + ruby-devel-1.8.5-5.el5_4.8 (using yum)&lt;br /&gt;
&lt;br /&gt;
3. python-2.4.3-24.el5 + python-devel-2.4.3-24.el5.x86_64 (using yum)&lt;br /&gt;
&lt;br /&gt;
4. libevent + libevent-devel - libevent-1.4.13-1/libevent-devel-1.4.13-1 (using yum)&lt;br /&gt;
&lt;br /&gt;
5. gcc-c++-4.1.2-46.el5_4.2&lt;br /&gt;
&lt;br /&gt;
6. boost 1.40 - &lt;a href=&quot;http://downloads.sourceforge.net/project/boost/boost/1.40.0/boost_1_40_0.tar.gz?use_mirror=softlayer&quot;&gt;http://downloads.sourceforge.net/project/boost/boost/1.40.0/boost_1_40_0.tar.gz?use_mirror=softlayer&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost] ./bootstrap.sh&lt;br /&gt;
[user@localhost] ./bjam&lt;br /&gt;
[user@localhost]  sudo su -&lt;br /&gt;
[root@localhost] ./bjam install&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
7. flex-2.5.4a-41.fc6 (using yum)&lt;br /&gt;
&lt;br /&gt;
8. m4-1.4.15 - &lt;a href=&quot;http://ftp.gnu.org/gnu/autoconf&quot;&gt;ftp.gnu.org/gnu/m4&lt;/a&gt; (do not use the version from yum)&lt;br /&gt;
&lt;br /&gt;
9. imake-1.0.2-3.x86_64 (using yum)&lt;br /&gt;
&lt;br /&gt;
10. autoconf-2.65 - &lt;a href=&quot;http://ftp.gnu.org/gnu/autoconf&quot;&gt;ftp.gnu.org/gnu/autoconf&lt;/a&gt; (do not use the version from yum)&lt;br /&gt;
&lt;br /&gt;
11. automake-1.11.1 - &lt;a href=&quot;http://ftp.gnu.org/gnu/automake&quot;&gt;ftp.gnu.org/gnu/automake&lt;/a&gt; (do not use the version from yum)&lt;br /&gt;
&lt;br /&gt;
12. libtool-2.2.6b - &lt;a href=&quot;http://ftp.gnu.org/gnu/libtool&quot;&gt;ftp.gnu.org/gnu/libtool &lt;/a&gt;(do not use the version from yum)&lt;br /&gt;
&lt;br /&gt;
13. bison-2.3-2.1 (using yum). It actually needs yacc. The following is to make yacc script that actually calls bison.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[root@localhost] more /usr/bin/yacc&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
exec bison -y &quot;$@&quot;&lt;br /&gt;
&lt;br /&gt;
[root@localhost] chmod +x /usr/bin/yacc&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
14. Latest version: &lt;a href=&quot;http://incubator.apache.org/thrift/download&quot;&gt;http://incubator.apache.org/thrift/download&lt;/a&gt;&lt;br /&gt;
thrift-0.2.0 - &lt;a href=&quot;http://archive.apache.org/dist/incubator/thrift/0.2.0-incubating&quot;&gt;http://archive.apache.org/dist/incubator/thrift/0.2.0-incubating&lt;/a&gt;&lt;br /&gt;
thrift-0.4.0 - &lt;a href=&quot;http://archive.apache.org/dist/incubator/thrift/0.4.0-incubating&quot;&gt;http://archive.apache.org/dist/incubator/thrift/0.4.0-incubating&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I am using thrift-0.2.0 in this example. &lt;br /&gt;
&lt;br /&gt;
[user@localhost] ./bootstrap.sh&lt;br /&gt;
[user@localhost] ./configure&lt;br /&gt;
&lt;br /&gt;
If you see this:&lt;br /&gt;
&lt;code&gt;error: ./configure: line 21183: syntax error near unexpected token `MONO,&#39;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Copy pkg.m4 in /usr/share/aclocal to thrift&#39;s aclocal directory. From the top-level thrift directory, do the following:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;cp /usr/share/aclocal/pkg.m4 aclocal&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Then again:&lt;br /&gt;
&lt;code&gt;[user@localhost] ./bootstrap.sh&lt;br /&gt;
[user@localhost] ./configure&lt;br /&gt;
[user@localhost] make&lt;br /&gt;
[user@localhost] sudo su -&lt;br /&gt;
[root@localhost] make install&lt;br /&gt;
[root@localhost] exit&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp; &lt;/code&gt;&lt;br /&gt;
You may see the following error when building thrift 0.4.0 and 0.5.0.&lt;br /&gt;
&lt;br /&gt;
make[4]: Entering directory `/home/user/pkgs/thrift-0.4.0/lib/cpp&#39;&lt;br /&gt;
/bin/sh ../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../.. -I/usr/local/include -I./src -Wall -g -O2 -MT ThreadManager.lo -MD -MP -MF .deps/ThreadManager.Tpo -c -o ThreadManager.lo `test -f &#39;src/concurrency/ThreadManager.cpp&#39; || echo &#39;./&#39;`src/concurrency/ThreadManager.cpp&lt;br /&gt;
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../.. -I/usr/local/include -I./src -Wall -g -O2 -MT ThreadManager.lo -MD -MP -MF .deps/ThreadManager.Tpo -c src/concurrency/ThreadManager.cpp -fPIC -DPIC -o .libs/ThreadManager.o In file included from src/concurrency/ThreadManager.cpp:20:&lt;br /&gt;
src/concurrency/ThreadManager.h:24:26: tr1/functional: No such file or directoryIn file included from src/concurrency/ThreadManager.cpp:20:&lt;br /&gt;
&lt;br /&gt;
Please change line 24 of ThreadManager.h from&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#include &amp;lt;tr1/functional&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
to&lt;br /&gt;
&lt;code&gt;#include &amp;lt;boost/tr1/tr1/functional&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
We also need to compile and install the Facebook fb303 library. From the top-level thrift directory:&lt;br /&gt;
&lt;code&gt;[user@localhost] cd contrib/fb303&lt;br /&gt;
[user@localhost] ./bootstrap.sh&lt;br /&gt;
[user@localhost] ./configure&lt;br /&gt;
[user@localhost] make&lt;br /&gt;
[user@localhost] sudo su -&lt;br /&gt;
[root@localhost] make install&lt;br /&gt;
[root@localhost] exit &lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
15. hadoop 0.21.0 - &lt;a href=&quot;http://www.apache.org/dyn/closer.cgi/hadoop/core/&quot;&gt;http://www.apache.org/dyn/closer.cgi/hadoop/core/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://archive.cloudera.com/cdh/testing/hadoop-0.20.1+169.89.tar.gz&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;code&gt;[user@localhost] cd hadoop-0.21.0/hdfs/src/c++/libhdfs&lt;br /&gt;
[user@localhost] ./configure JVM_ARCH=tune=k8 --with-java=/usr/java/jdk1.6.0_20&lt;br /&gt;
[user@localhost] make&lt;br /&gt;
[user@localhost] sudo su -&lt;br /&gt;
[root@localhost] cp .libs/libhdfs.so .libs/libhdfs.so.0 /usr/local/include &lt;br /&gt;
[root@localhost] cp hdfs.h /usr/local/include &lt;br /&gt;
[root@localhost] exit &lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
16. scribe-2.2 - &lt;a href=&quot;http://github.com/downloads/facebook/scribe/scribe-2.2.tar.gz&quot;&gt;http://github.com/downloads/facebook/scribe/scribe-2.2.tar.gz&lt;/a&gt; - have to use scribe-2.1 or above to support HDFS.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost] ./bootstrap.sh --enable-hdfs&lt;br /&gt;
[user@localhost] ./configure&lt;br /&gt;
[user@localhost] make&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
17. Configure and Run Hadoop (single-node cluster in this tutorial). &lt;br /&gt;
&lt;br /&gt;
a. First we need to modify a few configuration files. From top-level hadoop directory, edit conf/hadoop-env.sh, conf/core-site.xml, conf/hdfs-site.xml and conf/macoded-site.xml files.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost] more conf/hadoop-env.sh&lt;br /&gt;
&lt;br /&gt;
export HADOOP_OPTS=-Djava.net.codeferIPv4Stack=true&lt;br /&gt;
&lt;br /&gt;
# Set Hadoop-specific environment variables here.&lt;br /&gt;
&lt;br /&gt;
# The only required environment variable is JAVA_HOME.  All others are&lt;br /&gt;
# optional.  When running a distributed configuration it is best to&lt;br /&gt;
# set JAVA_HOME in this file, so that it is correctly defined on&lt;br /&gt;
# remote nodes.&lt;br /&gt;
&lt;br /&gt;
# The java implementation to use.  Required.&lt;br /&gt;
export JAVA_HOME=/usr/java/jdk1.6.0_20&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
&lt;br /&gt;
[user@localhost] more conf/core-site.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;configuration.xsl&quot;?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Put site-specific property overrides in this file. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
&amp;lt;property&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;hadoop.tmp.dir&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;value&amp;gt;/tmp/hadoop&amp;lt;/value&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;A base for other temporary directories.&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;property&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;fs.default.name&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;value&amp;gt;hdfs://localhost:9000&amp;lt;/value&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;The name of the default file system.  A URI whose&lt;br /&gt;
  scheme and authority determine the FileSystem implementation.  The&lt;br /&gt;
  uri&#39;s scheme determines the config property (fs.SCHEME.impl) naming&lt;br /&gt;
  the FileSystem implementation class.  The uri&#39;s authority is used to&lt;br /&gt;
  determine the host, port, etc. for a filesystem.&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[user@localhost] more conf/hdfs-site.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;configuration.xsl&quot;?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Put site-specific property overrides in this file. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
&amp;lt;property&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;dfs.replication&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;Default block replication.&lt;br /&gt;
  The actual number of replications can be specified when the file is created.&lt;br /&gt;
  The default is used if replication is not specified in create time.&lt;br /&gt;
  &amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[user@localhost] more conf/macoded-site.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;configuration.xsl&quot;?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Put site-specific property overrides in this file. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
&amp;lt;property&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;macoded.job.tracker&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;value&amp;gt;localhost:9001&amp;lt;/value&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;The host and port that the Macodeduce job tracker runs&lt;br /&gt;
  at.  If &quot;local&quot;, then jobs are run in-process as a single map&lt;br /&gt;
  and reduce task.&lt;br /&gt;
  &amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
b. Format the namenode. From top-level hadoop directory&lt;br /&gt;
&lt;code&gt;[user@localhost] bin/hadoop namenode -format&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
c. Start hadoop&lt;br /&gt;
&lt;code&gt;[user@localhost] start-all.sh&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
d. Use jps to check if all the processes are started.&lt;br /&gt;
&lt;code&gt;[user@localhost] jps&lt;br /&gt;
25362 JobTracker&lt;br /&gt;
24939 NameNode&lt;br /&gt;
25099 DataNode&lt;br /&gt;
25506 TaskTracker&lt;br /&gt;
25251 SecondaryNameNode&lt;br /&gt;
25553 Jps&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
e. Use netstat to check if port 9000 (set in core-site.xml) is listening.&lt;br /&gt;
&lt;code&gt;[user@localhost] sudo netstat -nap | grep 9000&lt;br /&gt;
sudo netstat -nap | grep 9000&lt;br /&gt;
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      24939/java         &lt;br /&gt;
tcp        0      0 127.0.0.1:9000              127.0.0.1:59957             ESTABLISHED 24939/java         &lt;br /&gt;
tcp        0      0 127.0.0.1:9000              127.0.0.1:59960             ESTABLISHED 24939/java         &lt;br /&gt;
tcp        0      0 127.0.0.1:59957             127.0.0.1:9000              ESTABLISHED 25099/java         &lt;br /&gt;
tcp        0      0 127.0.0.1:59960             127.0.0.1:9000              ESTABLISHED 25251/java    &lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
f. Open a browser and type server_ip:50070 to check if it shows 1 Live Nodes in the Cluster Summary. Be patient, sometimes it takes some time (30 seconds to 1 minute) to show. Remember to put the cursor to the address bar and codess enter to refresh the page. For some reason, F5 (Reload) doesn&#39;t work for me. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi41XStY0KNNmQFWejcrl-A-o3hHj7LjZg3FuOJjOox5h8DGCKfuRU1ktUKbML3kEILANOUrlYcwiGnhWwWuf9oPLA24Hjhbf6GWfjWgNPTFjKKVWc084QRhVpKAMTHlbBNTxQcxJ0ubKkL/s1600/dfshealth.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi41XStY0KNNmQFWejcrl-A-o3hHj7LjZg3FuOJjOox5h8DGCKfuRU1ktUKbML3kEILANOUrlYcwiGnhWwWuf9oPLA24Hjhbf6GWfjWgNPTFjKKVWc084QRhVpKAMTHlbBNTxQcxJ0ubKkL/s400/dfshealth.JPG&quot; height=&quot;285&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
18. Configure and Run Scribe&lt;br /&gt;
a. Set up the java class paths for Scribe. I have installed my hadoop 0.21.0 in ~/pkgs/hadoop-0.21.0 directory&lt;br /&gt;
&lt;br /&gt;
[user@localhost] export CLASSPATH=~/pkgs/hadoop-0.21.0/hadoop-hdfs-0.21.0.jar:~/pkgs/hadoop-0.21.0/lib/commons-logging-1.1.1.jar:~/pkgs/hadoop-0.21.0/hadoop-common-0.21.0.jar&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
b. Edit a Scribe configuration file to use HDFS. Change to scribe src directory&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost] more scribe_hdfs.conf&lt;br /&gt;
port=1463&lt;br /&gt;
max_msg_per_second=2000000&lt;br /&gt;
check_interval=3&lt;br /&gt;
&lt;br /&gt;
# DEFAULT&lt;br /&gt;
&amp;lt;store&amp;gt;&lt;br /&gt;
category=default&lt;br /&gt;
type=buffer&lt;br /&gt;
&lt;br /&gt;
target_write_size=20480&lt;br /&gt;
max_write_interval=1&lt;br /&gt;
buffer_send_rate=2&lt;br /&gt;
retry_interval=30&lt;br /&gt;
retry_interval_range=10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;primary&amp;gt;&lt;br /&gt;
type=file&lt;br /&gt;
fs_type=hdfs&lt;br /&gt;
file_path=hdfs://localhost:9000/scribetest&lt;br /&gt;
create_symlink=no&lt;br /&gt;
use_hostname_sub_directory=yes&lt;br /&gt;
base_filename=thisisoverwritten&lt;br /&gt;
max_size=40000000&lt;br /&gt;
rotate_period=daily&lt;br /&gt;
rotate_hour=0&lt;br /&gt;
rotate_minute=5&lt;br /&gt;
add_newlines=1&lt;br /&gt;
&amp;lt;/primary&amp;gt;&lt;br /&gt;
&amp;lt;secondary&amp;gt;&lt;br /&gt;
type=file&lt;br /&gt;
fs_type=std&lt;br /&gt;
file_path=/tmp/scribetest&lt;br /&gt;
base_filename=thisisoverwritten&lt;br /&gt;
max_size=3000000&lt;br /&gt;
&amp;lt;/secondary&amp;gt;&lt;br /&gt;
&amp;lt;/store&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
c. Run Scribe&lt;br /&gt;
&lt;code&gt;[user@localhost] scribed scribe_hdfs.conf&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;setrlimit error (setting max fd size)&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;STATUS: STARTING&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;STATUS: configuring&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;got configuration data from file &amp;lt;scribe_hdfs.conf&amp;gt;&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;CATEGORY : default&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;Creating default store&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;configured &amp;lt;1&amp;gt; stores&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;STATUS: &quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;STATUS: ALIVE&quot;&lt;br /&gt;
[Thu Sep  9 15:35:22 2010] &quot;Starting scribe server on port 1463&quot;&lt;br /&gt;
Thrift: Thu Sep  9 15:35:22 2010 libevent 1.4.13-stable method epoll&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
If it cannot run and complains the following:&lt;br /&gt;
&lt;code&gt;libboost_system.so.1.40.0: cannot open shared object&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Do the following:&lt;br /&gt;
&lt;code&gt;[user@localhost] echo &#39;/usr/local/lib/&#39; &amp;gt;&amp;gt; /etc/ld.so.conf.d/my_boost.conf&lt;br /&gt;
/sbin/ldconfig -v&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
If you see the following output when running scribe:&lt;br /&gt;
&lt;code&gt;[user@localhost] scribed scribe_hdfs.conf&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;setrlimit error (setting max fd size)&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;STATUS: STARTING&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;STATUS: configuring&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;got configuration data from file &amp;lt;scribe_hdfs.conf&amp;gt;&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;CATEGORY : default&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;Creating default store&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;configured &amp;lt;1&amp;gt; stores&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;STATUS: &quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;STATUS: ALIVE&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;Starting scribe server on port 1463&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;Exception in main: TNonblockingServer::serve() bind&quot;&lt;br /&gt;
[Thu Sep  9 15:39:38 2010] &quot;scribe server exiting&quot;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
It may be due to Port 1463 not being available. Run  &quot;netstat -nap | grep 1463&quot; to find out which program is using it.&lt;br /&gt;
&lt;br /&gt;
19. Send something to Scribe to log in HDFS&lt;br /&gt;
From a different terminal, in top-level Scribe directory:&lt;br /&gt;
&lt;code&gt;[user@localhost] echo &quot;hello world&quot; | examples/scribe_cat test&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
In the terminal that runs Scribe server, you should see the following output:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[Thu Sep  9 15:46:14 2010] &quot;[test] Creating new category from model default&quot;&lt;br /&gt;
[Thu Sep  9 15:46:14 2010] &quot;store thread starting&quot;&lt;br /&gt;
[Thu Sep  9 15:46:14 2010] &quot;[hdfs] Connecting to HDFS&quot;&lt;br /&gt;
[Thu Sep  9 15:46:14 2010] &quot;[hdfs] Before hdfsConnectNewInstance(localhost, 9000)&quot;&lt;br /&gt;
Sep 9, 2010 3:46:14 PM org.apache.hadoop.security.Groups &lt;init&gt;&lt;br /&gt;
INFO: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[hdfs] After hdfsConnectNewInstance&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[hdfs] Connecting to HDFS&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[hdfs] Before hdfsConnectNewInstance(localhost, 9000)&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[hdfs] After hdfsConnectNewInstance&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[hdfs] opened for write hdfs://localhost:9000/scribetest/test/localhost.localdomain/test-2010-09-09_00000&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[test] Opened file &lt;hdfs: localhost.localdomain=&quot;&quot; localhost:9000=&quot;&quot; scribetest=&quot;&quot; test-2010-09-09_00000=&quot;&quot; test=&quot;&quot;&gt; for writing&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[test] Opened file &lt;/hdfs:&gt; for writing&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[test] Changing state from &lt;disconnected&gt; to &lt;sending_buffer&gt;&quot;&lt;br /&gt;
Opening Primary&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[test] successfully read &amp;lt;0&amp;gt; entries from file &lt;/sending_buffer&gt;&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[test] No more buffer files to send, switching to streaming mode&quot;&lt;br /&gt;
[Thu Sep  9 15:46:15 2010] &quot;[test] Changing state from &lt;sending_buffer&gt; to &lt;streaming&gt;&quot;&lt;br /&gt;
&lt;/streaming&gt;&lt;/sending_buffer&gt;&lt;/disconnected&gt;&lt;/init&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
20. Check if the message has been logged to HDFS: &lt;br /&gt;
Stop Scribe first (either stop Scribe or make the file rotate, otherwise Hadoop won&#39;t write it to the filesystem.) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost] hadoop fs -lsr /&lt;br /&gt;
10/09/09 16:26:02 INFO security.Groups: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000&lt;br /&gt;
10/09/09 16:26:03 WARN conf.Configuration: macoded.task.id is decodecated. Instead, use macodeduce.task.attempt.id&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:21 /jobtracker&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:21 /jobtracker/jobsInfo&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:23 /scribetest&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:23 /scribetest/test&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:23 /scribetest/test/localhost.localdomain&lt;br /&gt;
-rw-r--r--   3 user supergroup         13 2010-09-09 16:25 /scribetest/test/localhost.localdomain/test-2010-09-09_00000&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:21 /tmp&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:21 /tmp/hadoop&lt;br /&gt;
drwxr-xr-x   - user supergroup          0 2010-09-09 16:21 /tmp/hadoop/macoded&lt;br /&gt;
drwx------   - user supergroup          0 2010-09-09 16:21 /tmp/hadoop/macoded/system&lt;br /&gt;
-rw-------   1 user supergroup          4 2010-09-09 16:21 /tmp/hadoop/macoded/system/jobtracker.info&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Get the directory out to take a look:&lt;br /&gt;
&lt;code&gt;[user@localhost] hadoop fs -get /scribetest test&lt;br /&gt;
10/09/09 16:26:47 INFO security.Groups: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000&lt;br /&gt;
10/09/09 16:26:47 WARN conf.Configuration: macoded.task.id is decodecated. Instead, use macodeduce.task.attempt.id&lt;br /&gt;
&lt;br /&gt;
[user@localhost] more test/test/localhost.localdomain/test-2010-09-09_00000&lt;br /&gt;
hello world&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
One note about the Secondary store in Scribe configuration file: Scribe opens the files for both Primary and Secondary stores even in the normal situation as long as replay_buffer is true (default). Then it will try to delete the secondary store file when Primary store is handling the messages. This is causing problem because HDFS has not completed its access to the secondary store file. The following exception will happen:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[Thu Sep  9 16:02:03 2010] &quot;[hdfs] deleteFile hdfs://localhost:9000/scribetest1/test/localhost.localdomain/test_00000&quot;&lt;br /&gt;
[Thu Sep  9 16:02:03 2010] &quot;[hdfs] Connecting to HDFS&quot;&lt;br /&gt;
[Thu Sep  9 16:02:03 2010] &quot;[hdfs] Before hdfsConnectNewInstance(localhost, 9000)&quot;&lt;br /&gt;
[Thu Sep  9 16:02:03 2010] &quot;[hdfs] After hdfsConnectNewInstance&quot;&lt;br /&gt;
[Thu Sep  9 16:02:03 2010] &quot;[test] No more buffer files to send, switching to streaming mode&quot;&lt;br /&gt;
Exception in thread &quot;main&quot; java.io.IOException: Could not complete write to file /scribetest1/test/localhost.localdomain/test_00000 by DFSClient_1545136365&lt;br /&gt;
        at org.apache.hadoop.hdfs.server.namenode.NameNode.complete(NameNode.java:720)&lt;br /&gt;
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)&lt;br /&gt;
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)&lt;br /&gt;
        at java.lang.reflect.Method.invoke(Method.java:597)&lt;br /&gt;
        at org.apache.hadoop.ipc.WritableRpcEngine$Server.call(WritableRpcEngine.java:342)&lt;br /&gt;
        at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1350)&lt;br /&gt;
        at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1346)&lt;br /&gt;
        at java.security.AccessController.doPrivileged(Native Method)&lt;br /&gt;
        at javax.security.auth.Subject.doAs(Subject.java:396)&lt;br /&gt;
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:742)&lt;br /&gt;
        at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1344)&lt;br /&gt;
&lt;br /&gt;
        at org.apache.hadoop.ipc.Client.call(Client.java:905)&lt;br /&gt;
        at org.apache.hadoop.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:198)&lt;br /&gt;
        at $Proxy0.complete(Unknown Source)&lt;br /&gt;
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;br /&gt;
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)&lt;br /&gt;
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)&lt;br /&gt;
        at java.lang.reflect.Method.invoke(Method.java:597)&lt;br /&gt;
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)&lt;br /&gt;
        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)&lt;br /&gt;
        at $Proxy0.complete(Unknown Source)&lt;br /&gt;
        at org.apache.hadoop.hdfs.DFSOutputStream.completeFile(DFSOutputStream.java:1406)&lt;br /&gt;
        at org.apache.hadoop.hdfs.DFSOutputStream.close(DFSOutputStream.java:1393)&lt;br /&gt;
        at org.apache.hadoop.fs.FSDataOutputStream$PositionCache.close(FSDataOutputStream.java:66)&lt;br /&gt;
        at org.apache.hadoop.fs.FSDataOutputStream.close(FSDataOutputStream.java:91)&lt;br /&gt;
Call to org/apache/hadoop/fs/FSDataOutputStream::close failed!&lt;br /&gt;
[Thu Sep  9 16:02:03 2010] &quot;[hdfs] closed hdfs://localhost:9000/scribetest1/test/localhost.localdomain/test_00000&quot;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
There is more information about this error in &quot;NameNode Logs&quot; link on http://server_ip:50070/dfshealth.jsp page.&lt;br /&gt;
&lt;br /&gt;
To avoid this problem we should either set replay_buffer to false or make the seconardy store local instead of HDFS (the above configuration file example, scribe_hdfs.conf).&lt;br /&gt;
&lt;br /&gt;
The following configuration is to set replay_buffer to false and both primary and secondary stores to use HDFS.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;[user@localhost] more hdfs_both.conf&lt;br /&gt;
port=1463&lt;br /&gt;
max_msg_per_second=2000000&lt;br /&gt;
check_interval=3&lt;br /&gt;
&lt;br /&gt;
# DEFAULT&lt;br /&gt;
&amp;lt;store&amp;gt;&lt;br /&gt;
category=default&lt;br /&gt;
type=buffer&lt;br /&gt;
replay_buffer=no&lt;br /&gt;
target_write_size=20480&lt;br /&gt;
max_write_interval=1&lt;br /&gt;
buffer_send_rate=2&lt;br /&gt;
retry_interval=30&lt;br /&gt;
retry_interval_range=10&lt;br /&gt;
&lt;br /&gt;
&amp;lt;primary&amp;gt;&lt;br /&gt;
type=file&lt;br /&gt;
fs_type=hdfs&lt;br /&gt;
file_path=hdfs://localhost:9000/scribetest&lt;br /&gt;
create_symlink=no&lt;br /&gt;
use_hostname_sub_directory=yes&lt;br /&gt;
base_filename=thisisoverwritten&lt;br /&gt;
max_size=40000000&lt;br /&gt;
rotate_period=daily&lt;br /&gt;
rotate_hour=0&lt;br /&gt;
rotate_minute=5&lt;br /&gt;
add_newlines=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/primary&amp;gt;&lt;br /&gt;
&amp;lt;secondary&amp;gt;&lt;br /&gt;
type=file&lt;br /&gt;
fs_type=hdfs&lt;br /&gt;
file_path=hdfs://localhost:9000/scribetest1&lt;br /&gt;
create_symlink=no&lt;br /&gt;
use_hostname_sub_directory=yes&lt;br /&gt;
base_filename=thisisoverwritten&lt;br /&gt;
max_size=40000000&lt;br /&gt;
rotate_period=daily&lt;br /&gt;
rotate_hour=0&lt;br /&gt;
rotate_minute=5&lt;br /&gt;
add_newlines=1&lt;br /&gt;
&amp;lt;/secondary&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/store&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
1. Thomas Dudziak&#39;s blog: &lt;a href=&quot;http://tomdzk.wordcodess.com/2010/01/19/how-to-install-scribe-with-hdfs-support-on-ubuntu-karmic/&quot;&gt;How  to install Scribe with HDFS support on Ubuntu Karmic&lt;/a&gt;&lt;br /&gt;
2. Agile Testing: &lt;a href=&quot;http://agiletesting.blogspot.com/2009/10/compiling-installing-and-test-running.html&quot;&gt;Compiling, installing and test-running Scribe&lt;/a&gt;&lt;br /&gt;
3. Google Scribe server group: &lt;a href=&quot;http://groups.google.com/group/scribe-server/browse_thread/thread/ce2b960331c39d60?pli=1&quot;&gt;Failover when writing to HDFS problems&lt;/a&gt;</description><link>http://knownsandunknowns.blogspot.com/2010/08/running-scribe-with-hdfs-support-on.html</link><author>noreply@blogger.com (ChiMaster)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi41XStY0KNNmQFWejcrl-A-o3hHj7LjZg3FuOJjOox5h8DGCKfuRU1ktUKbML3kEILANOUrlYcwiGnhWwWuf9oPLA24Hjhbf6GWfjWgNPTFjKKVWc084QRhVpKAMTHlbBNTxQcxJ0ubKkL/s72-c/dfshealth.JPG" height="72" width="72"/><thr:total>16</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-2395325451459638728</guid><pubDate>Tue, 17 Aug 2010 21:35:00 +0000</pubDate><atom:updated>2011-05-15T20:35:49.181-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computer architecture</category><category domain="http://www.blogger.com/atom/ns#">computer science</category><category domain="http://www.blogger.com/atom/ns#">jobs</category><category domain="http://www.blogger.com/atom/ns#">pipeline</category><category domain="http://www.blogger.com/atom/ns#">pipelining</category><title>Key Computer Architecture Techniques - Pipelining</title><description>&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Pipelining&lt;/b&gt;&lt;br /&gt;
It is an implementation technique where multiple instructions are overlapped in execution. The computer pipeline is divided in stages. Each stage completes a part of an instruction in parallel. The stages are connected one to the next to form a pipe - instructions enter at one end, progress through the stages, and exit at the other end.&lt;br /&gt;
&lt;br /&gt;
Because the pipe stages are hooked together, all the stages must be ready to proceed at the same time. We call the time required to move an instruction one step further in the pipeline  a machine cycle . The length of the machine cycle is determined by the time required for the slowest pipe stage.&lt;br /&gt;
&lt;br /&gt;
For example, the classic RISC pipeline is broken into five stages with a set of flip flops between each stage.&lt;br /&gt;
&lt;br /&gt;
1. Instruction fetch&lt;br /&gt;
2. Instruction decode and register fetch&lt;br /&gt;
3. Execute&lt;br /&gt;
4. Memory access&lt;br /&gt;
5. Register write back&lt;br /&gt;
&lt;br /&gt;
Pipelining does not help in all cases. There are several possible disadvantages. An instruction pipeline is said to be fully pipelined  if it can accept a new instruction every clock cycle. A pipeline that is not fully pipelined has wait cycles that delay the progress of the pipeline.&lt;br /&gt;
&lt;br /&gt;
Advantages of Pipelining:&lt;br /&gt;
&lt;br /&gt;
1. The cycle time of the processor is reduced, thus increasing instruction issue-rate in most cases.&lt;br /&gt;
&lt;br /&gt;
2. Some combinational circuits such as adders or multipliers can be made faster by adding more circuitry. If pipelining is used instead, it can save circuitry vs. a more complex combinational circuit.&lt;br /&gt;
&lt;br /&gt;
Disadvantages of Pipelining:&lt;br /&gt;
&lt;br /&gt;
1. A non-pipelined processor executes only a single instruction at a time. This prevents branch delays (in effect, every branch is delayed) and problems with serial instructions being executed concurrently. Consequently the design is simpler and cheaper to manufacture.&lt;br /&gt;
&lt;br /&gt;
2. The instruction latency in a non-pipelined processor is slightly lower than in a pipelined equivalent. This is due to the fact that extra flip flops (pipeline registers/buffers) must be added to the data path of a pipelined processor.&lt;br /&gt;
&lt;br /&gt;
3. A non-pipelined processor will have a stable instruction bandwidth. The performance of a pipelined processor is much harder to predict and may vary more widely between different programs.</description><link>http://knownsandunknowns.blogspot.com/2010/08/key-computer-architecture-techniques.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-1226926891072663841</guid><pubDate>Fri, 13 Aug 2010 18:02:00 +0000</pubDate><atom:updated>2010-08-13T13:29:26.232-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computer architecture</category><category domain="http://www.blogger.com/atom/ns#">jobs</category><category domain="http://www.blogger.com/atom/ns#">performance</category><title>Computer Performance</title><description>From &lt;a href=&quot;http://www.stanford.edu/class/ee282/handouts.html&quot;&gt;Stanford EE282&lt;/a&gt; + &lt;a href=&quot;http://www.amazon.com/Computer-Architecture-Quantitative-Approach-4th/dp/0123704901/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1281667504&amp;amp;sr=8-1&quot;&gt;Computer Architecture: A Quantitative Approach, 4th Edition&lt;/a&gt; &lt;span class=&quot;ptBrand&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Latency or execution time or response time&lt;/li&gt;

&lt;ul&gt;&lt;li&gt;Wall-clock time to complete a task&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&amp;nbsp;Bandwidth or throughput or execute rate&lt;/li&gt;

&lt;ul&gt;&lt;li&gt;Number of tasks completed per unit of time&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&amp;nbsp;Latency matric: program execution time&lt;br /&gt;
&lt;br /&gt;
CPUTime = Seconds/Program &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Cycles/Program * Seconds/Cycle &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Instructions/Program * Cycles/Instruction * Seconds/Cycle&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = IC * CPI * CCT&lt;br /&gt;
&lt;br /&gt;
IC: Instruction Count &lt;br /&gt;
CPI: Clock Cycles Per Instruction&lt;br /&gt;
CCT: Clock Cycle Time&lt;br /&gt;
&lt;br /&gt;
Amdahl’s Law&lt;br /&gt;
&lt;br /&gt;
Speedup = Execution time for entire task without using the enhancement/Execution time for entire task using the enhancement when possible &lt;br /&gt;
&lt;br /&gt;
It should be greater than 1 (when there is an improvement, that is)&lt;br /&gt;
&lt;br /&gt;
new_execution_time&lt;br /&gt;
= (original_execution_time * (1 - enhanced_fraction))&amp;nbsp; + original_execution_time * enhanced_fraction * (1 / speedup_enhanced)&lt;br /&gt;
= (original_execution_time)((1-enhanced_fraction) + enhanced_fraction/speedup_enhanced)&lt;br /&gt;
&lt;br /&gt;
speedup_overall&lt;br /&gt;
= original_execution_time / new_execution_time&lt;br /&gt;
= 1/((1-enhanced_fraction) + enhanced_fraction/speedup_enhanced)&lt;br /&gt;
&lt;br /&gt;
In the case of parallelization, Amdahl&#39;s law states that if enhanced_fraction is  the proportion of a program that can be made parallel (i.e. benefit from  parallelization), and (1 − enhanced_fraction) is the proportion that cannot be  parallelized (remains serial), then the maximum speedup that can be  achieved by using &lt;i&gt;N&lt;/i&gt; processors (N times faster for the part that can be enhanced = speedup_enhanced) is &lt;br /&gt;
&lt;br /&gt;
speedup_overall&lt;br /&gt;
&lt;br /&gt;
=  1/((1-enhanced_fraction) + enhanced_fraction/speedup_enhanced)&lt;br /&gt;
&lt;br /&gt;
In the limit, as &lt;i&gt;N&lt;/i&gt; tends to infinity, the maximum speedup  tends to 1 / (1 − enhanced_fraction).</description><link>http://knownsandunknowns.blogspot.com/2010/08/computer-performance.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-4595831480517911142</guid><pubDate>Fri, 06 Aug 2010 22:11:00 +0000</pubDate><atom:updated>2010-08-06T16:05:55.850-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">computer architecture</category><category domain="http://www.blogger.com/atom/ns#">diagram</category><category domain="http://www.blogger.com/atom/ns#">Intel</category><category domain="http://www.blogger.com/atom/ns#">Laptop</category><category domain="http://www.blogger.com/atom/ns#">Processor</category><title>System Diagram of A Modern Laptop</title><description>From &lt;a href=&quot;http://en.wikipedia.org/wiki/Intel_X58&quot;&gt;Wikipedia Intel X58&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU0wmLEoqfiI-Uvim8u0TdySOYi5EbcVu2misEBnio_g-YOJuLE442LQGu3kAAptU6-NF5BN0zRqQ5Cp91f8dems0vaZAQeuJ4kI2O21Y4ZK_Gi4-CWKio4DKdvk8NVmHWh8u1l989Oibn/s1600/719px-X58_Block_Diagram.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; bx=&quot;true&quot; height=&quot;532&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU0wmLEoqfiI-Uvim8u0TdySOYi5EbcVu2misEBnio_g-YOJuLE442LQGu3kAAptU6-NF5BN0zRqQ5Cp91f8dems0vaZAQeuJ4kI2O21Y4ZK_Gi4-CWKio4DKdvk8NVmHWh8u1l989Oibn/s640/719px-X58_Block_Diagram.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul&gt;&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Intel X58: Intel X58 Chipset&lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;QPI: The Intel QuickPath Interconnect&amp;nbsp;is a point-to-point processor interconnect developed by Intel to compete with HyperTransport&lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;I/O Controller Hub (ICH), also known as Intel 82801, is an Intel southbridge on motherboards with Intel chipsets (Intel Hub Architecture). As with any other southbridge, the ICH is used to connect and control peripheral devices.&lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;EHCI: The Enhanced Host Controller Interface (EHCI) specification describes the register-level interface for a Host Controller for the Universal Serial Bus (USB) Revision 2.0.&lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;DMI: Direct Media Interface (DMI) is point-to-point interconnection between an Intel northbridge and an Intel southbridge on a computer motherboard. It is the successor of the Hub Interface used in previous chipsets. It provides for a 10Gb/s bidirectional data rate.&lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;LPC: The Low Pin Count bus, or LPC bus, is used on IBM-compatible personal computers to connect low-bandwidth devices to the CPU, such as the boot ROM and the &quot;legacy&quot; I/O devices (behind a super I/O chip). &lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;SPI: The Serial Peripheral Interface Bus or SPI (pronounced &quot;ess-pee-i&quot; or &quot;spy&quot;) bus is a synchronous serial data link standard named by Motorola that operates in full duplex mode. Devices communicate in master/slave mode where the master device initiates the data frame. &lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Intel Matrix Storage Technology: It provides new levels of protection, performance, and expandability for desktop and mobile platforms. Whether using one or multiple hard drives, users can take advantage of enhanced performance and lower power consumption. When using more than one drive, the user can have additional protection against data loss in the event of a hard drive failure.&lt;/li&gt;
&lt;li class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Intel Turbo Memory with User Pinning: An on-motherboard flash card, Intel&#39;s Turbo Memory is designed to act as another layer in the memory hierarchy, caching data where possible and improving performance/battery life in notebooks. User pinning offers more options to the user to improve system applications launch time and responsiveness.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;</description><link>http://knownsandunknowns.blogspot.com/2010/08/system-diagram-of-modern-laptop.html</link><author>noreply@blogger.com (ChiMaster)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiU0wmLEoqfiI-Uvim8u0TdySOYi5EbcVu2misEBnio_g-YOJuLE442LQGu3kAAptU6-NF5BN0zRqQ5Cp91f8dems0vaZAQeuJ4kI2O21Y4ZK_Gi4-CWKio4DKdvk8NVmHWh8u1l989Oibn/s72-c/719px-X58_Block_Diagram.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-6951830754954844670</guid><pubDate>Fri, 06 Aug 2010 07:12:00 +0000</pubDate><atom:updated>2010-08-06T00:14:59.424-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c</category><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Heap Memory</title><description>From &lt;a href=&quot;http://cslibrary.stanford.edu/102/PointersAndMemory.pdf&quot;&gt;Stanford CS Ed Library: Pointers and Memory&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&quot;Heap&quot; memory, also known as &quot;dynamic&quot; memory, is an alternative to local stack memory. Local memory is quite automatic — it is allocated automatically on function call and it is deallocated automatically when a function exits. Heap memory is different in every way. The programmer explicitly requests the allocation of a memory &quot;block&quot; of a particular size, and the block continues to be allocated until the programmer&lt;br /&gt;
explicitly requests that it be deallocated. Nothing happens automatically. So the programmer has much greater control of memory, but with greater responsibility since the memory must now be actively managed. &lt;br /&gt;
&lt;br /&gt;
The advantages of heap memory are...&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Lifetime. Because the programmer now controls exactly when memory is allocated and deallocated, it is possible to build a data structure in memory, and return that data structure to the caller. This was never possible with local memory which was automatically deallocated when the function exited.&lt;/li&gt;
&lt;li&gt;Size. The size of allocated memory can be controlled with more detail. For example, a string buffer can be allocated at run-time which is exactly the right size to hold a particular string. With local memory, the code is more likely to declare a buffer size 1000 and hope for the best. &lt;/li&gt;
&lt;/ol&gt;The disadvantages of heap memory are...&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;More Work. Heap allocation needs to arranged explicitly in the code which is just more work. &lt;/li&gt;
&lt;li&gt;More Bugs. Because it&#39;s now done explicitly in the code, realistically on occasion the allocation will be done incorrectly leading to memory bugs. Local memory is constrained, but at least it&#39;s never wrong.&lt;/li&gt;
&lt;/ol&gt;Nonetheless, there are many problems that can only be solved with heap memory, so that&#39;s that way it has to be. In languages with garbage collectors such as Perl, LISP, or Java, the above disadvantages are mostly eliminated. The garbage collector takes over most of the responsibility for heap management at the cost of a little extra time taken at run-time.</description><link>http://knownsandunknowns.blogspot.com/2010/08/heap-memory.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-8271353919612005400</guid><pubDate>Thu, 05 Aug 2010 23:47:00 +0000</pubDate><atom:updated>2010-08-05T16:47:19.278-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c</category><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Classic swap function in C and C++</title><description>In C:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
void Swap(int* a, int* b) 
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

void SwapCaller() 
{
    int x = 1;
    int y = 2;
    // Use &amp;amp; to pass pointers to the int values of interest
    Swap(&amp;x, &amp;y); 
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
In C++:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
// The &amp; declares pass by reference
void Swap(int&amp; a, int&amp; b) 
{
    int temp;
    // No *&#39;s required -- the compiler takes care of it    
    temp = a;
    a = b;
    b = temp;
}

void SwapCaller() 
{
    int x = 1;
    int y = 2;
    // No &amp;&#39;s required -- the compiler takes care of it
    Swap(x, y); 
}
&lt;/code&gt;&lt;/pre&gt;</description><link>http://knownsandunknowns.blogspot.com/2010/08/classic-swap-function-in-c-and-c.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-1631433199046064134</guid><pubDate>Thu, 05 Aug 2010 21:53:00 +0000</pubDate><atom:updated>2010-08-05T14:53:53.372-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c</category><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">stack</category><title>How Does Call Stack Work?</title><description>From &lt;a href=&quot;http://cslibrary.stanford.edu/102/PointersAndMemory.pdf&quot;&gt;Stanford CS Ed Library: Pointers and Memory&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The exact details of the implementation are language and compiler specific. However, the basic structure below is approximates the method used by many different systems and languages...&lt;br /&gt;
&lt;br /&gt;
To call a function such as foo(6, x+1)...&lt;br /&gt;
&lt;br /&gt;
1. Evaluate the actual parameter expressions, such as the x+1, in the caller&#39;s context.&lt;br /&gt;
&lt;br /&gt;
2. Allocate memory for foo()&#39;s locals by pushing a suitable &quot;local block&quot; of memory onto a runtime &quot;call stack&quot; dedicated to this purpose. For parameters but not local variables, store the values from step (1) into the appropriate slot in foo()&#39;s local block.&lt;br /&gt;
&lt;br /&gt;
3. Store the caller&#39;s current address of execution (its &quot;return address&quot;) and switch execution to foo().&lt;br /&gt;
&lt;br /&gt;
4. foo() executes with its local block conveniently available at the end of the call stack.&lt;br /&gt;
&lt;br /&gt;
5. When foo() is finished, it exits by popping its locals off the stack and &quot;returns&quot; to the caller using the previously stored return address. Now the caller&#39;s locals are on the end of the stack and it can resume executing.</description><link>http://knownsandunknowns.blogspot.com/2010/08/how-does-call-stack-work.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-5138829467991129005</guid><pubDate>Mon, 12 Jul 2010 23:35:00 +0000</pubDate><atom:updated>2014-09-24T10:41:00.218-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Algorithms</category><category domain="http://www.blogger.com/atom/ns#">c</category><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">computer science</category><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">Sorting</category><title>Algorithms - Sorting</title><description>From Wikipedia &lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm&quot;&gt;Sorting Algorithm&lt;/a&gt;.&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;mw-headline&quot; id=&quot;Bubble_sort&quot;&gt;Bubble sort&lt;/span&gt;&lt;/h3&gt;
&lt;i&gt;Bubble sort&lt;/i&gt; is a straightforward and simplistic method of sorting data that is used in computer science education. The algorithm starts at the beginning of the data set. It compares the first two elements, and if the first is greater than the second, then it swaps them. It continues doing this for each pair of adjacent elements to the end of the data set. It then starts again with the first two elements, repeating until no swaps have occurred on the last pass. This algorithm is highly inefficient, and is rarely used&lt;sup&gt;,&lt;/sup&gt; except as a simplistic example. &lt;br /&gt;
Bubble sort average case and worst case are both O(&lt;i&gt;n&lt;/i&gt;²).&lt;br /&gt;


&lt;pre&gt;&lt;code&gt;
ResultCode BubbleSort(int a[], int nSize)
{
    ResultCode res = SORT_FAILED;
    int i, j = 0;
    bool bSwap = true;
    int tmp;
    if (a)
    {
        while (bSwap)
        {
            bSwap = false;
            j++;
            for (i = 0; i &amp;lt; (nSize - j); i++)
            {
                if (a[i] &amp;gt; a[i + 1])
                {
                    tmp = a[i];
                    a[i] = a[i + 1];
                    a[i + 1] = tmp;
                    bSwap = true;
                }
            }
        }
        res = SORT_OK;
    }
    return res;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;mw-headline&quot; id=&quot;Selection_sort&quot;&gt;Selection sort&lt;/span&gt;&lt;/h3&gt;
&lt;i&gt;Selection sort&lt;/i&gt; is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
ResultCode SelectionSort(int numbers[], int array_size)
{
    int i, j;
    int min, temp;
    ResultCode res = SORT_FAILED;
    if (numbers)
    {
        // for each number, find the min from the list of i to the end
        // and then swap the min with i;
        for (i = 0; i &amp;lt; array_size-1; i++)
        {
            // set min to i
            min = i;
            // check each one from i + 1 to the end of the array
            // to find the minimum number from the list of numbers
            // from i+1 to the end
            for (j = i+1; j &amp;lt; array_size; j++)
            {
                // if any number is less than the min, set min to the new index
                if (numbers[j] &amp;lt; numbers[min])
                {
                    min = j;
                }
            }
            // swap the minimum with i
            temp = numbers[i];
            numbers[i] = numbers[min];
            numbers[min] = temp;
        }
         res = SORT_OK;
    }
    return res;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;
&lt;span class=&quot;mw-headline&quot; id=&quot;Insertion_sort&quot;&gt;Insertion sort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Insertion_sort&quot; title=&quot;Insertion sort&quot;&gt;Insertion sort&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;Insertion sort&lt;/i&gt; is a simple sorting algorithm that is relatively efficient for small lists and mostly-sorted lists, and often is used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list. In arrays, the new list and the remaining elements can share the array&#39;s space, but insertion is expensive, requiring shifting all following elements over by one. &lt;a href=&quot;http://en.wikipedia.org/wiki/Shell_sort&quot; title=&quot;Shell sort&quot;&gt;Shell sort&lt;/a&gt; (see below) is a variant of insertion sort that is more efficient for larger lists.&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
ResultCode InsertionSort(int arr[], int length)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int i, j, tmp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ResultCode res = SORT_FAILED;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (arr)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 1; i &amp;lt; length; i++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j = i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (j &amp;gt; 0 &amp;amp;&amp;amp; arr[j - 1] &amp;gt; arr[j])&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp = arr[j];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arr[j] = arr[j - 1];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arr[j - 1] = tmp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j--;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res = SORT_OK;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return res;&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;mw-headline&quot; id=&quot;Shell_sort&quot;&gt;Shell sort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Shell_sort&quot; title=&quot;Shell sort&quot;&gt;Shell sort&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;Shell sort&lt;/i&gt; was invented by &lt;a href=&quot;http://en.wikipedia.org/wiki/Donald_Shell&quot; title=&quot;Donald Shell&quot;&gt;Donald Shell&lt;/a&gt; in 1959. It improves upon bubble sort and insertion sort by moving out of order elements more than one position at a time. One implementation can be described as arranging the data sequence in a two-dimensional array and then sorting the columns of the array using insertion sort.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
ResultCode ShellSort(int num[], int length)
{
    int i, temp, flag = 1;
    int d = length;
    ResultCode res = SORT_FAILED;
    if (num)
    {
        while(flag || (d &amp;gt; 1))
        {
            flag = 0;                     
            d = (d + 1) / 2; // use (d + 1)/2 as the gap
            // starting from positon 0 to length - d - 1, comparing num[i] 
            //and num[i+d]
            for (i = 0; i &amp;lt; (length - d); i++)  
            {
                if (num[i + d] &amp;gt; num[i])
                {
                    // swap positions i+d and i
                    temp = num[i + d];         
                    num[i + d] = num[i];
                    num[i] = temp;
                    // tells swap has occurred
                    flag = 1;                                   }
            }
        }
        res = SORT_OK;
    }
    return res;
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;editsection&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mw-headline&quot; id=&quot;Binary_tree_sort&quot;&gt;Binary tree sort&lt;/span&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;
typedef struct tree_el {
   int val;
   struct tree_el * right, * left;
} node;

void BinaryTreeSort(node **tree, node *item)
{
   if(!(*tree)) {
      *tree = item;
      return;
   }
   if(item-&amp;gt;val &amp;lt;= (*tree)-&amp;gt;val)
      BinaryTreeSort(&amp;amp;(*tree)-&amp;gt;left, item);
   else if(item-&amp;gt;val&amp;gt;(*tree)-&amp;gt;val)
      BinaryTreeSort(&amp;amp;(*tree)-&amp;gt;right, item);
}

void printout(node * tree) {
   if(tree-&amp;gt;left) printout(tree-&amp;gt;left);
   printf(&quot;%d\n&quot;,tree-&amp;gt;val);
   if(tree-&amp;gt;right) printout(tree-&amp;gt;right);
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;editsection&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mw-headline&quot; id=&quot;Merge_sort&quot;&gt;Merge sort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Merge_sort&quot; title=&quot;Merge sort&quot;&gt;Merge sort&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;Merge sort&lt;/i&gt; takes advantage of the ease of merging already sorted lists into a new sorted list. It starts by comparing every two elements (i.e., 1 with 2, then 3 with 4...) and swapping them if the first should come after the second. It then merges each of the resulting lists of two into lists of four, then merges those lists of four, and so on; until at last two lists are merged into the final sorted list. Of the algorithms described here, this is the first that scales well to very large lists, because its worst-case running time is O(&lt;i&gt;n&lt;/i&gt; log &lt;i&gt;n&lt;/i&gt;). Merge sort has seen a relatively recent surge in popularity for practical implementations, being used for the standard sort routine in the programming languages &lt;a href=&quot;http://en.wikipedia.org/wiki/Perl&quot; title=&quot;Perl&quot;&gt;Perl&lt;/a&gt;&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-4&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm#cite_note-4&quot;&gt;[5]&lt;/a&gt;&lt;/sup&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Python_%28programming_language%29&quot; title=&quot;Python (programming language)&quot;&gt;Python&lt;/a&gt; (as &lt;a href=&quot;http://en.wikipedia.org/wiki/Timsort&quot; title=&quot;Timsort&quot;&gt;timsort&lt;/a&gt;&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-5&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm#cite_note-5&quot;&gt;[6]&lt;/a&gt;&lt;/sup&gt;), and &lt;a href=&quot;http://en.wikipedia.org/wiki/Java_%28programming_language%29&quot; title=&quot;Java (programming language)&quot;&gt;Java&lt;/a&gt; (also uses timsort as of &lt;a class=&quot;mw-redirect&quot; href=&quot;http://en.wikipedia.org/wiki/JDK7&quot; title=&quot;JDK7&quot;&gt;JDK7&lt;/a&gt;&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-6&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm#cite_note-6&quot;&gt;[7]&lt;/a&gt;&lt;/sup&gt;), among others. Merge sort has been used in Java at least since 2000 in JDK1.3.&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-mergesort_in_jdk13_7-0&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm#cite_note-mergesort_in_jdk13-7&quot;&gt;[8]&lt;/a&gt;&lt;/sup&gt;&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-jdk13_since_2000_8-0&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Sorting_algorithm#cite_note-jdk13_since_2000-8&quot;&gt;[9]&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
void Merge(int a[], int low, int high, int mid)
{
    int i, j, k, c[high - low];
    i = low;
    j = mid + 1;
    k = 0;

    while((i &amp;lt;= mid) &amp;amp;&amp;amp; (j &amp;lt;= high))
    {
        if (a[i] &amp;lt; a[j])
        {
            c[k] = a[i];
            k++;
            i++;
        }
        else
        {
            c[k] = a[j];
            k++;
            j++;
        }
    }
    while (i &amp;lt;= mid)
    {
        c[k] = a[i];
        k++;
        i++;
    }
    while(j &amp;lt;= high)
    {
        c[k] = a[j];
        k++;
        j++;
    }
    for(i = low; i &amp;lt; (high + 1); i++)
    {
        a[i] = c[i - low];
    }
}


ResultCode MergeSort(int a[], int low, int high)
{
    ResultCode res = SORT_FAILED;
    int mid;

    if (a)
    {
        if (low &amp;lt; high)
        {
            mid = (low + high) / 2;
            MergeSort (a, low, mid);
            MergeSort(a, mid + 1, high);
            Merge(a, low, high, mid);
        }
        res = SORT_OK;
    }
    return res;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;
&lt;span class=&quot;editsection&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mw-headline&quot; id=&quot;Heapsort&quot;&gt;Heapsort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Heapsort&quot; title=&quot;Heapsort&quot;&gt;Heapsort&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;Heapsort&lt;/i&gt; is a much more efficient version of &lt;a href=&quot;http://en.wikipedia.org/wiki/Selection_sort&quot; title=&quot;Selection sort&quot;&gt;selection sort&lt;/a&gt;. It also works by determining the largest (or smallest) element of the list, placing that at the end (or beginning) of the list, then continuing with the rest of the list, but accomplishes this task efficiently by using a data structure called a &lt;a href=&quot;http://en.wikipedia.org/wiki/Heap_%28data_structure%29&quot; title=&quot;Heap (data structure)&quot;&gt;heap&lt;/a&gt;, a special type of &lt;a href=&quot;http://en.wikipedia.org/wiki/Binary_tree&quot; title=&quot;Binary tree&quot;&gt;binary tree&lt;/a&gt;. Once the data list has been made into a heap, the root node is guaranteed to be the largest(or smallest) element. When it is removed and placed at the end of the list, the heap is rearranged so the largest element remaining moves to the root. Using the heap, finding the next largest element takes &lt;i&gt;O(log n)&lt;/i&gt; time, instead of &lt;i&gt;O(n)&lt;/i&gt; for a linear scan as in simple selection sort. This allows Heapsort to run in &lt;i&gt;O(n log n)&lt;/i&gt; time, and this is also the worst case complexity.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
// node index starts at 0
#define left(i) 2*i+1
#define right(i) 2*i+2

// In computer science, a heap is a specialized tree-based data structure
// that satisfies the heap property: if B is a child node of A, then
// key(A) = key(B). This implies that an element with the greatest key is
// always in the root node, and so such a heap is sometimes called a max-heap.
void max_heapify(int a[],int i,int size)
{
    int l,r,largest,temp;
    l=left(i);
    r=right(i);
    if(l&amp;lt;=size-1 &amp;amp;&amp;amp; a[l]&amp;gt;a[i])
        largest = l;
    else largest = i;
    if(r&amp;lt;=size-1 &amp;amp;&amp;amp; a[r]&amp;gt;a[largest])
        largest = r;
    if(largest != i)
    {
        temp = a[i];
        a[i]=a[largest];
        a[largest]=temp;
        // since we change the value of the &quot;largest&quot; (index) node,
        // we have to make sure there is still a max heap below that.
        max_heapify(a,largest,size);
    }
}
void build_max_heap(int a[],int size)
{
    int i;
    // starting from rightmost parent going upward.
    for(i=size/2 - 1 ;i&amp;gt;=0;i--)
        max_heapify(a,i,size);
}
ResultCode HeapSort(int a[],int size)
{
    int i,temp;
    ResultCode res = SORT_FAILED;
    if (a)
    {

        build_max_heap(a,size);
        for(i=size-1;i&amp;gt;0;i--)
        {
            // swap the root (largest value) and the end
            temp=a[i];
            a[i]=a[0];
            a[0]=temp;
            size=size - 1;
            max_heapify(a,0,size);
        }
        res = SORT_OK;
    }
    return res;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;editsection&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mw-headline&quot; id=&quot;Quicksort&quot;&gt;Quicksort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Quicksort&quot; title=&quot;Quicksort&quot;&gt;Quicksort&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;Quicksort&lt;/i&gt; is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm&quot; title=&quot;Divide and conquer algorithm&quot;&gt;divide and conquer&lt;/a&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Algorithm&quot; title=&quot;Algorithm&quot;&gt;algorithm&lt;/a&gt; which relies on a &lt;i&gt;partition&lt;/i&gt; operation: to partition an array, we choose an element, called a &lt;i&gt;pivot&lt;/i&gt;, move all smaller elements before the pivot, and move all greater elements after it. This can be done efficiently in linear time and &lt;a href=&quot;http://en.wikipedia.org/wiki/In-place_algorithm&quot; title=&quot;In-place algorithm&quot;&gt;in-place&lt;/a&gt;. We then recursively sort the lesser and greater sublists. Efficient implementations of quicksort (with in-place partitioning) are typically unstable sorts and somewhat complex, but are among the fastest sorting algorithms in practice. Together with its modest O(log &lt;i&gt;n&lt;/i&gt;) space usage, this makes quicksort one of the most popular sorting algorithms, available in many standard libraries. The most complex issue in quicksort is choosing a good pivot element; consistently poor choices of pivots can result in drastically slower O(&lt;i&gt;n&lt;/i&gt;²) performance, but if at each step we choose the &lt;a href=&quot;http://en.wikipedia.org/wiki/Median&quot; title=&quot;Median&quot;&gt;median&lt;/a&gt; as the pivot then it works in O(&lt;i&gt;n&lt;/i&gt;&amp;nbsp;log&amp;nbsp;&lt;i&gt;n&lt;/i&gt;). Finding the median, however, is an O(n) operation on unsorted lists, and therefore exacts its own penalty.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
ResultCode QuickSort(int arr[], int left, int right)
{

    int i = left, j = right;
    int tmp;
    ResultCode res = SORT_FAILED;
    if (arr)
    {
        int pivot = arr[(left + right) / 2];
        /* partition */
        while (i &amp;lt;= j)
        {
            while (arr[i] &amp;lt; pivot)
            {
                i++;
            }
            while (arr[j] &amp;gt; pivot)
            {
                j--;
            }
            if (i &amp;lt;= j)
            {
                tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
                i++;
                j--;
            }
        };
        /* recursion */
        if (left &amp;lt; j)
        {
            QuickSort(arr, left, j);
        }
        if (i &amp;lt; right)
        {
            QuickSort(arr, i, right);
        }
        res = SORT_OK;
    }
    return res;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;editsection&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mw-headline&quot; id=&quot;Counting_Sort&quot;&gt;Counting Sort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Counting_sort&quot; title=&quot;Counting sort&quot;&gt;Counting sort&lt;/a&gt;&lt;/div&gt;
Counting sort is applicable when each input is known to belong to a particular set, &lt;i&gt;S&lt;/i&gt;, of possibilities. The algorithm runs in O(|&lt;i&gt;S&lt;/i&gt;| + &lt;i&gt;n&lt;/i&gt;) time and O(|&lt;i&gt;S&lt;/i&gt;|) memory where &lt;i&gt;n&lt;/i&gt; is the length of the input. It works by creating an integer array of size |&lt;i&gt;S&lt;/i&gt;| and using the &lt;i&gt;i&lt;/i&gt;th bin to count the occurrences of the &lt;i&gt;i&lt;/i&gt;th member of &lt;i&gt;S&lt;/i&gt; in the input. Each input is then counted by incrementing the value of its corresponding bin. Afterward, the counting array is looped through to arrange all of the inputs in order. This sorting algorithm cannot often be used because &lt;i&gt;S&lt;/i&gt; needs to be reasonably small for it to be efficient, but the algorithm is extremely fast and demonstrates great asymptotic behavior as &lt;i&gt;n&lt;/i&gt; increases. It also can be modified to provide stable behavior.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
ResultCode CountingSort (int array[], int size)
{
    int i, min, max;
    ResultCode res = SORT_FAILED;
    if (array)
    {
        min = max = array[0];
        for(i = 1; i &amp;lt; size; i++)
        {
            if (array[i] &amp;lt; min)
                min = array[i];
            else if (array[i] &amp;gt; max)
                max = array[i];
        }
        // under the assumption of range being smaller than size, or it&#39;s 
        // not worth it.
        int range = max - min + 1;
        int *count = (int *)malloc(range * sizeof(int));

        for(i = 0; i &amp;lt; range; i++)
        {
            count[i] = 0;
        }
        // count index + 2 is the value,
        // counting freqency of that value.
        for(i = 0; i &amp;lt; size; i++)
        {
            count[ array[i] - min ]++;
        }
        int j, z = 0;
        for(i = min; i &amp;lt;= max; i++)
        {
            for(j = 0; j &amp;lt; count[ i - min ]; j++)
            {
                array[z++] = i;
            }
        }
        free(count);
        res = SORT_OK;
    }
    return res;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;editsection&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mw-headline&quot; id=&quot;Bucket_sort&quot;&gt;Bucket sort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Bucket_sort&quot; title=&quot;Bucket sort&quot;&gt;Bucket sort&lt;/a&gt;&lt;/div&gt;
Bucket sort is a &lt;a href=&quot;http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm&quot; title=&quot;Divide and conquer algorithm&quot;&gt;divide and conquer&lt;/a&gt; sorting algorithm that generalizes &lt;a href=&quot;http://en.wikipedia.org/wiki/Counting_sort&quot; title=&quot;Counting sort&quot;&gt;Counting sort&lt;/a&gt; by partitioning an array into a finite number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. Thus this is most effective on data whose values are limited (e.g. a sort of a million integers ranging from 1 to 1000). A variation of this method called the single buffered count sort is faster than quicksort and takes about the same time to run on any set of data.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;

// Here array is the array to be sorted and n is the number of buckets to 
// use. The function msbits(x,k) returns the k most significant bits of x 
// (msbits = floor(x/2^(size(x)-k)), floor function returns the largest 
// integral value not greater than x.)
// uucket sort assumes that the input is generated by a random process 
// that distributes elements uniformly over the interval [0, 1), in this 
// code, the range is [0, 999]
ResultCode BucketSort(int *a,int n)
{
    vector&lt;int&gt; bucket[10];
    int i, j;
    int idx = 0;

    ResultCode res = SORT_FAILED;
    if (a)
    {
        for (i = 0; i &amp;lt; n; i++)
        {
            bucket[(a[i]/100)].push_back(a[i]);
        }
        for (i = 0; i &amp;lt; 10; i++)
        {
            // creating a new array.
            int arr[bucket[i].size()];

            // copy the vector data to array because our InsertionSort 
            // accepts array.
            for (j = 0; j &amp;lt; bucket[i].size(); j++)
            {
                arr[j] = bucket[i][j];
            }

            InsertionSort(arr, bucket[i].size());
            // put the sorted bucket to the original array.
            for (j = 0; j &amp;lt; bucket[i].size(); j++)
            {
                a[idx++] = arr[j];
            }
        }
        res = SORT_OK;
    }
    return res;
}
&lt;/int&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span class=&quot;mw-headline&quot; id=&quot;Radix_sort&quot;&gt;Radix sort&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;rellink relarticle mainarticle&quot;&gt;
Main article: &lt;a href=&quot;http://en.wikipedia.org/wiki/Radix_sort&quot; title=&quot;Radix sort&quot;&gt;Radix sort&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;Radix sort&lt;/i&gt; is an algorithm that sorts a list of fixed-size numbers of length &lt;i&gt;k&lt;/i&gt; in O(&lt;i&gt;n&lt;/i&gt; · &lt;i&gt;k&lt;/i&gt;) time by treating them as bit strings. We first sort the list by the least significant bit while preserving their relative order using a stable sort. Then we sort them by the next bit, and so on from right to left, and the list will end up sorted. Most often, the &lt;a href=&quot;http://en.wikipedia.org/wiki/Counting_sort&quot; title=&quot;Counting sort&quot;&gt;counting sort&lt;/a&gt; algorithm is used to accomplish the bitwise sorting, since the number of values a bit can have is minimal - only &#39;1&#39; or &#39;0&#39;.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
ResultCode RadixSort(int *a,int n)
{
    int i;
    int b[n], m=0, exp=1;
    ResultCode res = SORT_FAILED;

    if (a)
    {
        // Find the maximum number
        for (i=0;i&lt;n a=&quot;&quot; i=&quot;&quot; if=&quot;&quot;&gt; m)
            {
                m = a[i];
            }
        }

        // starting from the last digit
        while ((m/exp) &amp;gt; 0)
        {
            int bucket[10]={0};

            // put each number in the bucket according to the value in the 
            // inspected digit
            for(i = 0; i &amp;lt; n; i++)
            {
                bucket[(a[i]/exp) % 10]++;
            }

            // accumulate the values to the buckets
            for(i = 1;i &amp;lt; 10; i++)
            {
                bucket[i] += bucket[i-1];
            }

            // smart!
            // use the bucket value - 1 (because it&#39;s the sequence!) to 
            // for indices of the new array.
            for(i = n-1;i &amp;gt;= 0; i--)
            {
                b[--bucket[a[i]/exp%10]] = a[i];
            }
            for(i = 0;i &amp;lt; n;i++)
            {
                a[i] = b[i];
            }
            exp*=10;
        }
        res = SORT_OK;

    }

    return res;
}
&lt;/n&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 480;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Name&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Average&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Worst&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Memory&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Stable&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Method&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Notes&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Bubble Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Exchanging&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Tiny code&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Selection Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Depends&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Selection&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Its stability depends on the implementation. Used to sort&lt;br /&gt;
this table in Safari or other &lt;span class=&quot;SpellE&quot;&gt;Webkit&lt;/span&gt; web browser&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 3;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Insertion Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Insertion&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Average case is also O(n + d), where d is the number of&lt;br /&gt;
inversions&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 4;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Shell Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
-&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
nlog&lt;sup&gt;2&lt;/sup&gt;n&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
No&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Insertion&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 5;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Binary Tree Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Insertion&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
When using a &lt;a href=&quot;http://en.wikipedia.org/wiki/Self-balancing_binary_search_tree&quot; title=&quot;Self-balancing binary search tree&quot;&gt;self-balancing binary search tree&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 6;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Merge Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Merging&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Used to sort this table in Firefox&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 7;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;Heapsort&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
1&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
No&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Selection&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 8; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;Quicksort&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 74.8pt;&quot; valign=&quot;top&quot; width=&quot;100&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;nlogn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 83pt;&quot; valign=&quot;top&quot; width=&quot;111&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 88.3pt;&quot; valign=&quot;top&quot; width=&quot;118&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;span class=&quot;SpellE&quot;&gt;logn&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 70.65pt;&quot; valign=&quot;top&quot; width=&quot;94&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Depends&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 71.1pt;&quot; valign=&quot;top&quot; width=&quot;95&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Partitioning&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 89.15pt;&quot; valign=&quot;top&quot; width=&quot;119&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Can be implemented as a stable sort depending on how the&lt;br /&gt;
pivot is handled. Naïve variants use O(n) space&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
The following table describes sorting algorithms that are not comparison sorts. As such, they are not limited by a O(nlogn) lower bound. Complexities below are in terms of n, the number of items to be sorted, k, the size of each key, and s, the chunk size used by the implementation. Many of them are based on the assumption that the key size is large enough that all entries have unique key values, and hence that n &amp;lt;&amp;lt; 2&lt;i&gt;&lt;sup&gt;k&lt;/sup&gt;&lt;/i&gt;, where &amp;lt;&amp;lt; means &quot;much less than.&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 480;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Name&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 68.2pt;&quot; valign=&quot;top&quot; width=&quot;91&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Average&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.8pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Worst&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Memory&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Stable&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;mso-bidi-font-style: italic;&quot;&gt;n&lt;/span&gt;&lt;br /&gt;
&amp;lt;&amp;lt; 2&lt;sup&gt;&lt;span style=&quot;mso-bidi-font-style: italic;&quot;&gt;k&lt;/span&gt;&lt;/sup&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Notes&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 1;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Bucket Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 68.2pt;&quot; valign=&quot;top&quot; width=&quot;91&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n * k&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.8pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;sup&gt;2 &lt;/sup&gt;* k&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n * k&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
No&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Assumes uniform distribution of elements from the domain&lt;br /&gt;
in the array.&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 2;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Counting Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 68.2pt;&quot; valign=&quot;top&quot; width=&quot;91&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n + k&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.8pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n + k&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n + 2&lt;sup&gt;k&lt;/sup&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
If k = O(n) then RT = O(n)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;mso-yfti-irow: 3; mso-yfti-lastrow: yes;&quot;&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 95.4pt;&quot; valign=&quot;top&quot; width=&quot;127&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
LSD Radix Sort&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 68.2pt;&quot; valign=&quot;top&quot; width=&quot;91&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n * k/s&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.8pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n * k/s&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
n&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
Yes&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;text-align: center;&quot;&gt;
No&lt;/div&gt;
&lt;/td&gt;&lt;td style=&quot;border-bottom: windowtext 1pt solid; border-left: medium none; border-right: windowtext 1pt solid; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 81.75pt;&quot; valign=&quot;top&quot; width=&quot;109&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://knownsandunknowns.blogspot.com/2010/07/algorithms-sorting.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3687361113178920589.post-1542445359333328642</guid><pubDate>Sat, 10 Jul 2010 06:53:00 +0000</pubDate><atom:updated>2010-07-12T16:33:40.534-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">cygwin</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">unix</category><category domain="http://www.blogger.com/atom/ns#">Vista</category><category domain="http://www.blogger.com/atom/ns#">Windows</category><title>Installing and building your C++ programs in Cygwin on Windows Vista</title><description>Installation: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Run or download setup.exe from this link: http://www.cygwin.com/setup.exe.&lt;/li&gt;
&lt;li&gt;Select &quot;Install from Internet&quot; &amp;amp; &quot;Direct Connection&quot; if that&#39;s your Internet setting. &lt;/li&gt;
&lt;li&gt;Keep the recommended Root Directory and &quot;Install for&quot; if you don&#39;t feel like changing them.&lt;/li&gt;
&lt;li&gt;Select your Internet connection&lt;/li&gt;
&lt;li&gt;On Select Packages window, Open &quot;Devel&quot; to select gdb &amp;amp; open &quot;Editor&quot; to select vim if you want vi (I know, I&#39;m old-fashioned...)&lt;/li&gt;
&lt;/ol&gt;On Windows Vista, browse to &quot;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Cygwin&quot; directory, press right mouse button on Cygwin Bash Shell file, selection Properties-&amp;gt;Advanced. Check &quot;Run as administrator&quot;&lt;br /&gt;
&lt;br /&gt;
Run Cygwin Bash Shell from Programs list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Building your first C++ program&lt;br /&gt;
$ g++ yourprog.cpp&lt;br /&gt;
&lt;br /&gt;
If you see the following error:&lt;br /&gt;
“This application has requested the Runtime to terminate it in an unusual way”&lt;br /&gt;
&lt;br /&gt;
Add the following:&lt;br /&gt;
export TEMP=/tmp to your ~/.bashrc file&lt;br /&gt;
&lt;br /&gt;
Close and restart your Cygwin Bash Shell.</description><link>http://knownsandunknowns.blogspot.com/2010/07/installing-and-building-your-c-programs.html</link><author>noreply@blogger.com (ChiMaster)</author><thr:total>0</thr:total></item></channel></rss>