Shortcut for chapter specific information

Wednesday, May 4, 2011

Some TAOCP readings: merge sort, sequential search and my first MIXAL.

Among the three classic textbooks.  TAOCP is probably the most difficult to read.  The requirement on math is certainly an issue but I found the most difficult part is to understand MIX and MIXAL.  My honest reaction to MIX and MIXAL is - why would anyone use it? 

If I was going to write a book about programming, I would certainly used C or probably Intel Assembly language.   But after I understand the first MIX program, a sequential Search in Chapter 6, only 7 lines but it's already a wrestle for me,  I start to understand why Prof. Knuth would want to do things like that.  (See Listing 1)

      K EQU 10
      N EQU 10
    KEY EQU 200
   INFO EQU 210
START LDA 10
      ENT1 1-N
2H    CMPA KEY+N,1
      JE SUCCESS
      INC1 1
      J1NP 2B
FAILURE EQU *
SUCCESS LDA INFO+N,1
EXIT JMP *



The reason why MIX is used is to convince the reader that programming is independent of the choice of language.  So if the language is created within a book, one can still use it to analyze programs.   Their properties would just be exactly the same as written in any programming languages!

Of course, once you figure out the meaning of every line of the program and how it works.  You can start to see the beauty of it as well!

In a way, Prof. Knuth is like the Tolkien in C.S. He create a new language within his book which is quite an epic like The Lord of the Rings.

* 5.2.4 is a mysterious to me.
* 6.1 opens my eyes.   I have no idea there are so much to think about in sequential search.  I should implement linear search as part of practice.

2 comments:

  1. Well, I could understand since Knuth started back in the 1960s (when assembly language was the default language used) he was just using conventions of the time.

    But why invent a new assembly language? To accurately report how efficient an algorithm is, would be my guess.

    If you know how many clock cycles each opcode takes, you can use mathematical induction to say "This algorithm on average requires f(n) clock cycles".

    But yeah, MIXAL is peculiar by today's standards...

    ReplyDelete
  2. It is Nelson, it is.....

    It doesn't make the experience of reading TAOCP less rewarding though.

    ReplyDelete