Shortcut for chapter specific information

Tuesday, May 31, 2011

Long Weekend

Three things happened during the weekend.
  • I was sick.  With headache and temperature,
  • Finished ZAMM,
  • Watched the first lecture of MIT "Introduction to Algorithm".
Got to get back to studying.   But getting sick is one gumption trap.  My current strategy?  Try to finish simple stuffs and get through the darkest time when you don't feel you want to learn more.   I will first write up my experience on these 3 small issues.  Then move on again.

Sunday, May 29, 2011

My recent stuckness.

For the first time, I have come to a point I feel stuck when I try to proceed in CLRS.   In my case, that means the three threads (browse read, exercise read and deep read) I have been working on are not moving.

Naturally, I am thinking about why.  For each read, there are different reasons and I also figure out their solutions. 
  • For my browse read, my understanding of tree, or generally my understanding in discrete mathematics, need to be improved quickly.   Many of the questions require some intuitive understanding of trees.   I will not open the daunting Rosen's Discrete Mathematics and Its Applications.   Because I am fully aware of the damage of studying two text books at the same time.   I will feel too burn out and feeling not learning anything.  What I will do is to study Appendix B of CLRS and perhaps read the whole Chapter 2 of TAOCP.  Then reread, chapter 12 and 13. This should prepare me better on the next reread. 
  • For my exercise read, as I mention before, I am beaten up by the exercises.   My solution is to go to sleep and take some mental break from Algorithms   In fact, I already line up couple of things to do while I am taking the mental break from algorithm.  That includes memorizing 80 Kanjis and also read El Alquimista in Spanish.   Both are within reach and fun to do. 
  • For my deep read, I just need to work on it one item by item.  It is meant to be a deep connecting study to try to combine everything I know.   This is a phase which takes time.   I am just going to take my time and enjoy the process. 
And yes, enjoy!  Enjoy algorithms.  Indeed, there are many material reasons why I want to study programming.  But at the end of the day, it is fun!  It is also something which makes me tick the most in Computer Science.

Saturday, May 28, 2011

Great Quote from Prof. Leiserson

I just watch on-line video for lecture 1 of the MIT open courseware in "Introduction to Algorithm".  Great Lecture! and I think I learn a lot from it.  It's bed time, so I will put down the best quote from Prof. Leiserson, one of the course lecturers.

"If you want to be a good program, you just program ever day for two years, you will be an excellent programmer. If you want to be a world-class programmer, you can program every day for ten years, or you can program every day for two years and take an algorithms class."


I am so glad I hear this.  Though it's a bit late for me but I still feel it worths it. 

Updated complementary exercises for CLRS 20110529


Chapter 2 General:
-Watch the MIT video if it is only about Ch2. (done)
-Write up the summary of the video. 
-Read all the solution sets after I finished the videos. 
-work out cost analysis similar to P.26 on selection sort, linear search and merge sort (tedious).

-Think how to draw the recursion tree for the insertion sort algorithm. 
-Work out all proofs for the following algorithms
  -insertion sort
  -selection sort
  -bubble sort
  -binary insertion sort
  -merge sort
  -linear search
  -binary search
-Implement 2.3.7, P2.1, Horner's rule in P2.3 and inversion calculation in P2.4.  2.3.7 has two solutions, one is trivial, one is based on merge.  Think them through.


Chapter 3 General
-TAOCP? Knuth must have talk about Big Oh at a certain point.  (done)
-Read the Wikipedia's entries in the big Oh notation, iterative logarithm and all Math related subject.
-Alternative definitions of the asymptotic notion. 
-Finish all exercises of Sedgewick Chapter 2.
-Finish all exercises below Level 25 of TAOCP Section 1.1 and 1.2 
-What is the difference between the definitions of Sedgewick with CLRS?

Insertion sort:
-C, perl, python (done)
-sentinel version of straight insertion sort (done)
-binary search (done, now a separate item)
-binary insertion sort (done, now a separate item)
-recursive version of insertion sort (done)
-start to write a performance driver
-shell sort, how does the decrement business works?

   -Pratt's increments.
   -Sedgewick's increments.
-library sort
-tree sort(from wikipedia, what is it?)

-insertion sort improvement, all suggested by Exercises from TAOCP. 
-insertion sort with linked list
-How does the idea of insert leads to merge sort?
-C++,java, lisp, ASM, TAOCP Pseudo, TAOCP MIX, TAOCP MMIX.
-performance, worst case, average case
-different ways to avoid -INT_MAX as the sentinel. (state of art?)
-non-adaptive version of insertion sort.
-TAOCP Exercises in 5.2.1
-Sedgewick 6.3 Exercises

Selection sort:
-C, perl, python (done)
-C++,java, lisp, ASM
-stable version of selection sort.
-bidirectional version of selection sort.
-comparison with insertion sort.
-comparison with bubble sort
-recursive version of insertion sort
-cycle sort
-heap sort variants
     -tournament sort
     -smoothsort.
-TAOCP Exercise in 5.2.3
-Sedgewick 6.2
-Sedgewick 6.2 Exercise
Binary Insertion sort:
-C (done)
-perl, python, C++, java, lisp, ASM

Bubble sort:
-C (done)
-shaker sort
-perl, python, java, lisp, ASM
-TAOCP 5.2.2

Merge sort:
-C, perl(done)
-python, C++,java, lisp, ASM
-timsort
-performance, worst case, average case
-Improvements from Sedgewick.
-Non-recursive version or Bottom up version
-in place mergesort.
-no extra memory implementation (state of art?)
-variations of merge sort. 
-implement merge sort with k list and a k-list merging. 2.4.1.
-TAOCP Exercise in 5.4
-Sedgewick 8 (read - done)
-Sedgewick 8 Exercises.
-Shene's 5-9 Exercises. 
-where can I find problems which apply merging? 
  -Implement CLRS 2.3-7 using merging
  -like to calculate number of inversions.

Linear search:
-C, MIXAL (done)
-perl, python, C++,java, lisp, ASM
-TAOCP 6.1 and exercises.  Remember, it's not as trivial as you may think. 

Binary search: 
-C (done)
-perl, python, C++,java, lisp, ASM
-At least 100 problems which applies binary search.
   -TopCoder's exercises on binary search. 
   -Implement CLRS 2.3-7.
   -Shene Chapter 4. 
-After reading Gries, make sure you prove your own binary search is correct. 
-TAOCP 6.2 and exercises. 
-Chapter 4 and 5 of Programming Pearl exercises. 
-Sedgewick 12.4
-Fibonacci search
-Range search
-Variations of binary search. 
-Thinking: variations of binary search.  They produce different lo, up bounds. Interesting. 
-Thinking: can we combine the idea of distribution in binary search?
-Thinking: what happens if binary search is applied to a sequence with N inversions?

Inversions: 
-Try to understand TAOCP 5.1 as much as I can. 

-Try to do exercises in TAOCP 5.1. 

Thoughts on Chapter 3

I just finished another subpart of the exercise.   For me, I think this is probably the most effective way to get through the material.

I am certainly seeking for some kind of mental break since I started to feel tired (and sick too) after concentrating in the same material.    First thing I did was to go through some future chapters.   After finishing Chapter 3, I understand the other materials more.   As always, Math and Algorithms always favor people who reiterate.

What bugs me is that I was beaten up by two problems in Chapter 3.  It's not the fact the I can't solve them is a problem.  But the fact that how I resolve the question I don't know is the biggest problem.

For the question with star, they are meant to be difficult.  So I should take my time and think it through.  For example 3.2-4, if I spend a little bit of time to think it through, I should be able to solve it myself.

All is not lost.   What I hope to do in the next 2 days is to first distract myself a bit with something else.  My hope is to remember 80 kanjis before my next Japanese class.  I will spend two days on it.  After that, algorithm time!

Status 20110528 (e)


Resolved both P3.2a and P3.2c in my head. 

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-5, P3-{1,2}, P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 5.1-{1,2}, 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a), A.1-{1,2,3,5,7}, C.1-{2,4,5,7,8,9,14}, C.2-{1,2,4,5}, C.3-{1,2,10}, all in D.1. and D.2-2.

Status 20110528 (d)


Finished in my head: all exercises in Section D.1 and D.2-2.  Rather trivial, the toughest of them will not go beyond the Math you see in "Matrix Analysis". 

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-5, P3-1,P3.2(b,d-f), P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 5.1-{1,2}, 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a), A.1-{1,2,3,5,7}, C.1-{2,4,5,7,8,9,14}, C.2-{1,2,4,5}, C.3-{1,2,10}, all in D.1. and D.2-2.

Status 20110528 (c)


Finished in my head: A.1-{1,2,3,5,7}.

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-5, P3-1,P3.2(b,d-f), P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 5.1-{1,2}, 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a), A.1-{1,2,3,5,7}, C.1-{2,4,5,7,8,9,14}, C.2-{1,2,4,5}, C.3-{1,2,10}

Appendix A: Summations

Read it once, pretty quickly figured out 5 out of 8 problems.   Few of them are tricky mathematically (and I was too lazy in calculus..... now it's time to make it up).

By itself, summations have tons of tricks.   That makes me feel excited.  But as I said, I am still just side-tracking to later chapters at this point so not until Chapter 5, I probably won't finish all the exercises on paper.

Zen and the Art of Motorcycle Maintenance (Part 7)

Finished another 40 pages of the book.  When Prisig discuss the idea of gumption trap, I cannot feel this is more closer than I have been thinking in my work in research and programming.

Prisig discuss several traps of not being able to attain quality.   Unlike most authors, his discussion is filled with deep insight in psychology and philosophy.   For example, his analysis on why human got distracted from attaining quality spot on on why I have not been doing well in my work.

There are many traps in succeeding in resolving deep technical and skill problems.    The first important thing is the failure of caring.  This is caused by ego, anxiety and boredom.  And those are the true feelings of programmers and skillful workers in the world.    We appear to be the wizards of technology.   But deep down, we feel like all human beings.  We are scared of the nature which can give us a problem that we cannot resolve.

Let me try to give an example, in my reading of CLRS, I find traps to many programmers and make them not able to finish the whole book.   Here is the reason why many of them cannot finish the whole book or gumption traps as discussed by Prisig. That includes the following.  (Mostly self-criticism btw.)

  • Having fuzzy belief that CLRS is "reference book" but not an "introductory book".   (How do you define "introductory" and "reference"?  If you don't specify the background knowlege of a person, how do you know?")
  • It's too long a book.  (War and Peace in Signet Classic has 1400 pages.  A typical Dickens is 500 pages.  Believe it or not, people read these books and they are not necessarily literature major. )
  • Having fuzzy belief that CLRS is "too mathematical" so it is "useless in real life situation" (In real life, what operation was actually not control by some kind of logical or mathematical structure?)
  • They are not "smart enough" and only have a fuzzy understanding of what "smartness" means.  (In fact, have you ever try to define what smartness is?  Do some research, you will see how fuzzy a concept it is.)
  • Caught up by one single exercise in the book.  (Record the attempts of solving a problem.  No one is so perfect that they can resolve all mathematical problems.   Or else the twin prime problems is resolved by someone already.   If you think giving up is a shame, remember that there are many people who look at the Twin Prime problem, the Goldbach conjecture, the Fermat's Last Theorem and then decide to give up and sleep.  So no shame, this is just how human works. )
  • Not trying to learn an algorithm as one should learn it.  (Algorithm is not meant to be "read", it's meant to be "implemented".  This explains why an early chapter such as Chapter 2 take some time for people to "read" it through.  Because the truth is one needs to at least implement an algorithm once to get a rough understanding of its operation.)
  • "I don't need to know all the algorithms from CLRS. For example, why do I read Chapter 5? I will never write a random generator in my whole life."  (The reason why you want to learn algorithm is not because a particular algorithm would be used but because you want to learn the pattern on how to solve a problem.  For example, binary search as a method can be used to resolve more than just searching.  In general, it is a method you can operate on a range of numbers.  Consider the binary insertion sort, it takes a fine understanding of binary search.   For another example, random generation algorithm will make you start to wonder what probability really is.  Again, it is the thinking which matters, not the proper nouns and sound byte. )
  • "I tried to read the book, but the later content lost me." (That's because you haven't learnt the material in the previous chapters well enough.  Try to build connection on concepts, read further reference and repeat the process.)
  • It just takes too much time.  (When I scrutinize my use of time, I can always find some wasteful moment I can dedicate them to study algorithms.  If you did the same and have none, I have nothing to say.)
These are the gumption traps for reading an algorithm book.  In fact, I start to see why I sometimes I fail in the other attempts in my other ventures.  

But I am confident now, my biggest weakness, algorithm, will one day become one of my biggest strength.   Just like many other things such as video gaming, language learning, poker, lock picking etc.

Status 20110528 (b)


Finished in my head: P3.2b

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-5, P3-1,P3.2(b,d-f), P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 5.1-{1,2}, 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),  C.1-{2,4,5,7,8,9,14}, C.2-{1,2,4,5}, C.3-{1,2,10}

Chapter 5 Reread and Appendix C

I decided to let myself drift for a while because exercises in CLRS 3.2 beat me up quite a bit.  So I need to let my mind relaxed for a while because I think I don't perform well.

My way to deal with such kind of problems is to look ahead of the book.   This usually motivates me because you will start to see all these fundamental materials become necessary to understand more.   For example, if you truly want to understand quick sort and heap sort, then you need to know much of the materials in Chapter 5.  Or else your calculation will become quite messy.  If you want to solve recurrence in general, you have to go through Chapter 4.  Or else most of the time, you will be hit or miss guessing a formula.

I quickly browsed through the material in Chapter 5.  Chapter 5 can be thought of as the toughest chapter out of all the introductory chapters (Chapter 2 to 5).  It requires math outside of just an algorithm book and it probably take a class of random process or statistics to fully understand.

But I am curiously attracted to such a difficulty.  The question in my mind is always "Why not?".   If this  is the exercises are difficult, why I am not able to solve it?  I will just beat them one day.  That's my thinking.

Many programmers, just like me, try to read CLRS from the beginning, they are all stumbled in Chapter 5 because it suddenly requires math and stats which go beyond their comfort zone.   Some people will also doubt the introductory book status of CLRS.   To me, that's ridiculous, being good in probability and math is important in nearly every facet of life.  You want to understand lottery? Probability.  You want to understand election? Probability.   You want to know how merge sort really works but not just copying? Math and probability.   So getting good at it while you have time, (you have time because you are reading CLRS already), it's certainly very beneficial.

In fact this difficulty of reading Chapter 5 is mitigated by the authors, who put most introductory material into the Appendices.   My plan is if I got stuck in Chapter 5, I will first exercises from both Appendix A and Appendix C first.  (In fact, I have already finished some of them.) Why not? This is a good refreshment of what I learned in the past anyway.

Status 20110528


Finished in my head: 5.1-1, 5.1-2, C.1-2, C.1-4, C.1-5, C.1-7, C.1-8, C.1-9, C.1-14, C.2-1, C.2-2, C.2-4, C.2-5, C.2.9, C.3-1, C.3-2, C.3-10

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-5, P3-1,P3.2(d-f), P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 5.1-{1,2}, 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),  C.1-{2,4,5,7,8,9,14}, C.2-{1,2,4,5}, C.3-{1,2,10}

Friday, May 27, 2011

Need to take a rest

I have been thinking about algorithm pretty intensively and certainly need a break.  Let's slow down in this long weekend.  

Ah, I guess it's time to join DELE to learn how good/bad my Spanish is.

Status 20110527(c)

Finished write up P3.2(d-f). Each requires one to understand certain relationship between functions. 

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-5, P3-1, P3.2(d-f), P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a).

status 20110527(b)

Finished write up 3-2.3 and 3-2.7

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.4.  Also finished 3-2.{6,7,8}. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-{5}, Part-finished 3.2-8, P3-1, P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a).

status 20110527

Finished write up 3-2.8.  As I mentioned, I wasn't able to resolve the issue.  I also revisit P2.1c.  Both of them I should write up before I claim I finish Chapter 3.
 
Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.3.  Also finished 3-2.6, 3-2.8. 
Needs write up: 3-2.8, P2.1c
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-{3,5,7}, Part-finished 3.2-8, P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),

CLRS 3-2.8 and CLRS P2.1c

Hmm.  I revisit both the problems.   I got to say, the whole Oh, Theta and Omega notations are tricky to grasp.  I will certainly write them up here at some point.

Also read TAOCP 1.2.10.  Note that the properties of the set of Oh are explained well in the text as well as the exercises.

Zen and the Art of Motorcycle Maintenance (Part 6)

Read another 10 pages. Now starting Chapter 26.  This is indeed a difficult book to read.

Prisig suggested that one should unify both the subject and the object sides of quality together in a fundamental level.   I don't know how this could be done but I know when this feeling appears to me.

Have you written a merge sort in the past?   In the traditional top-down merge sort.  There are usually three pieces of code: the merge function, the merge_sort function and the driver of the program.

When I look at individual piece, they look fairly ugly before you understand what they do as a whole.

After I finally got it running (,search merge_sort in this blog for my attempts), the feelings are entirely different.   What a marvelous idea!  In fact there is even an easy proof of its performance.

Then I went back to each of the program.  Another feeling kicks in, wow, the program is indeed very smart.   For a typical C implementation, you just need to pass in a piece of working memory.  But the code does the magic.  Unsorted array becomes sorted.   How wonderful.

It is feeling like this keep us programmers working.  Not money, not reputation, not fame.   It is this beautiful feeling to get new things working make us keep on.

I guess we all have this feeling daily.  It just a matter of recognizing it consciously.

I yield to CLRS 3-2.8

I spent around 3 hours on it.  So I gave up and look up the solution on-line.  As it turns out, it depends on whether you interpret the problem correctly (and I certainly overthink).

I will probably write it up when I have time.

Thursday, May 26, 2011

TAOCP 1.2.11.2 - Euler's Summation Formula, Bernoulli's number, Stirling's Approximation

Reread TAOCP 1.2.11.2.  This chapter is extremely nice because it makes me understanding 3 things.
  • You can approximate a series with an integral. 
  • Why Bernoulli's number is so important
  • How one can derive Stirling's Approximation (in particular, how that can be derived from Euler's summation formula.
It's worthwhile to memorize the formula.

status 20110526 (a)

Solved 3-2.1, 3-2.2 and 3-2.6. Spent some time on 3-2.8, still hadn't completely attacked it.

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.3.  Also finished 3-2.6
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-{3,5,7}, Part-finished 3.2-8, P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),
Revisit: (af Ch3) P2.1c

Zen and the Art of Motorcycle Maintenance (Part 5)

I waked up early this morning at 5 and ended up finish a lot of housework.  Everyone needs one of these days which you can be alerted and work out something which is important long term.

Then I continued to read ZAMM and finished another 40 pages.  Once again, I feel this is one of the most important book I read intellectually since I came to the U.S..  In the world of knowledge, there are generally two types of knowledge, one is based on logic, arguments, or what Prisig calls "the classical knowledge".  There is also another knowledge which expressed only in artistic manner and aesthetic.  Or what Prisig calls "the romantic knowledge".  In real-life, one will constantly face situation where one needs to apply both so called classical knowledge and the romantic knowledge.   This is especially true if you are serious about something.

In my case, I found that I need to exercise my mind intensively on several activities.  That includes (sort of in the descending order of importance) Learning, Thinking, Reading, Writing, Science, Mathematics, Programming, Philosophy, Psychology.   To a lesser extent, all the Games I like to play.  I found that in all these cases, both types of knowledge are need.  You will also see that people who are bad in doing them are the ones who always think this subject as only one sided.

I frankly got to admit that I was stuck in several of these subjects.  For example, in Science, I always found that I am a lesser scientist than people around me.  I know people who can solve a problem faster than me.   In writing, there are always people come by and tell me how my writing is bad.  Same happens in programming.

I always feel lost about these issues.  To an extent, the issue really boils down to what "good" is for these subjects.   If you really think about it, and just like what Prisig realized, it is extremely hard to define what "good" is in writing and programming. Or in Science and Math, it's tough to ask what a good research is.

But the strange thing is we all know what "good" is when we look at the writing, or the program, or the research papers.  This has always been baffled me.  I believe Prisig has given me a very good idea.  I would not say I agree or disagree with his thought.  But at least I feel great that someone think deeply in those issues.

If you like to think and read this message, I strongly suggest you to read ZAMM.  I believe it resolves many issues for smart people.

Wednesday, May 25, 2011

Distracted today

This is another one of those dangerous moment in reading a tough book.  You just a significant portion of it but there seems to be a lot of thing to do before you can get to another level.  Some of these are difficult and you may run into the danger which you might not solve it. In that case, what you should do

  • Simplify the list of things you want to do. 
  • Try to go ahead on 1 or 2 questions just to make yourself feel happy. 
33_P

Why people fail in language learning?

Other than my day time work and algorithm drills, one of my hobbie is to learn foreign language.  I am a Chinese so naturally I know two dialects, an official dialect, i.e. Mandarin and a dialect of the region, i.e. Cantonese.   I speak and write reasonable to room-to-improve English.  Since I am not a professional writer, I gathered that's reasonable.  So I switched away from English and try to learn the "foreign language" in America, Spanish.  If I succeeded this time, it would be my forth language.

Spanish is not the first "forth language" I tried to master. Before Spanish, I tried to learn Japanese, Korean, Italian and Esperanto.  I also picked up some small artificial language such Navi, Toki Pona and Klingon.   While I have complete success in Toki Pona (because it has 100 words), I gave up all of them at the end.   I have restarted Japanese recently.  But so far, Spanish is the language I go the farthest.   At this point, I would proudly say I learn all the tenses and have lively conversations with any Spanish speakers who can tolerate my poor accents and occasional incomprehensible grammar.   Despite the shortcomings of my Spanish, I have been clearly improving rapidly.   In fact, when I told my professor I only learn the language for a year, he was very surprised because many people took several years to come to my level.  Not only you will doubt his statement.  I had a lot of doubt as well because it doesn't make any logical sense.

In fact, for the most parts of her, America has foreign language learning program.  Though it's astounding to see not many people in the States can master more than English.   America has been culturally tolerant to other races for quite a number of years.   That makes me wonder whether there are other reasons why people failed.  

There are many possible reasons for this, but after a while I believe there are three ultimate reasons.   The first is that generally we are not taught about the general structure of languages.  When I said "general structure", I mean the common parts which is universal for all, or at least most of the languages. 

There are two important corollaries of the first reason.  One is that many people don't realize that a language can impose a completely different world view to human beings.   What do I mean by imposing different world views? For example, in Spanish may be you can say "correr un riesgo" to mean "to run the risk".   You cannot say "está calor" (is heat) but you can only say "tiene calor" (have heat).  Since each language imposed a different views of  the world, many people cannot get used to it.  

If you went to a language class, this kind of questions come up all the time.  "How do I say A from language X in language Y?"  The teacher will give you a translation.  Sometimes it could make no sense to a speaker in language X, so the first reaction for a intelligent person in language X is that "How can people think in this way?" 

What the learner didn't know is that "of course, there is a reason for every small tidbits in another language from etymological to historical but a person doesn't has to know them before they go on".   This type of problem appears in many level of language learning.

Another related observations - many learners in Spanish, French and Italian are very interested in learning new nouns.  But they are stumbled on learning verbs because verbs are the hard part.  

There are many irregular verbs in the above three languages.   So an effective way to learn these language is rather surprising - one should simply acquire 500-1000 verbs of that language using technique such as rote training.  After that one can then start the phase of acquiring different type of words such as adjectives and nouns through reading and perhaps listening.

The second reason, which is also a result of lack of knowledge about language itself, is that the most important factor of language learning is actually not the intelligence of the learner.  Rather, language learning is more an issue of persistence.  That is if you are willing to spend more time on it.  This sounds like a clique.  So why would I say it with such confidence. 

One just need to look at the recent advances of computer speech recognition, then it would be completely clear that the clique thinking is actually not wrong.  For a computer, equipped with correct algorithm, the performance of a speech recognition algorithm is usually not determined by the cleverness of the algorithm.   Rather it is determined by the number of hours the recognition model is trained.  

So what is the consequence of this observation?  It's clear that if we spend more time on a language, we can be improved.  It's also clear that when a person give up a certain study and restart.  It would be much harder.   So the conclusion is one should try not to give up in a language study.  If one starts to learn and not able to pick up immediately, one should try their best to stay on course and keep on learning.   That is paradoxically the most effective way to learn.

This funny reason is actually why many students decide to quit or ignore their language studies.  Many students, after seeing their peers have mastered more than them, decide to give up.  That happens a lot because at a certain moment, there got to be someone who is better than you in something.  Most of the time, they feel that they cannot catch up.  So at the end, they decide to give up.  

In my observations, the said students can be very talented in a certain aspect of the language.  May be they have good articulation of phonemes in a certain language.  May be they are natural in repeating and learning grammars.   In any cases, they just have to work on a part of the skill.  Then they are done.  But many people just cannot go over this hurdle.

In conclusion, I would think that language learning illustrate a concept which is deeper than language learning itself.  That is how we should learn something usually depends on our abstract understanding about something.  If more students understand the fundamentals and mechanics of language itself, I believe more and more people will speak foreign language fluently in  USA. 

33_P

Tuesday, May 24, 2011

Updated complementary exercises for CLRS 20110525(a)

Chapter 2 General:
-Watch the MIT video if it is only about Ch2. 
-Work out all proofs for the following algorithms
  -insertion sort
  -selection sort
  -bubble sort
  -binary insertion sort
  -merge sort
  -linear search
  -binary search
-Implement 2.3.7, P2.1, Horner's rule in P2.3 and inversion calculation in P2.4.  2.3.7 has two solutions, one is trivial, one is based on merge.  Think them through.
-Read all the solution sets after I finished the first 3 items.
-work out cost analysis similar to P.26 on selection sort, linear search and merge sort (tedious).

Chapter 3 General
-TAOCP? Knuth must have talk about Big Oh at a certain point.  (done)
-Read the Wikipedia's entries in the big Oh notation, iterative logarithm and all Math related subject.
-Alternative definitions of the asymptotic notion. 
-Finish all exercises of Sedgewick Chapter 2.
-Finish all exercises below Level 25 of TAOCP Section 1.1 and 1.2
-What is the difference between the definitions of Sedgewick with CLRS?

Insertion sort:
-C, perl, python (done)
-sentinel version of straight insertion sort (done)
-binary search (done, now a separate item)
-binary insertion sort (done, now a separate item)
-recursive version of insertion sort (done)
-start to write a performance driver
-shell sort, how does the decrement business works?

   -Pratt's increments.
   -Sedgewick's increments.
-library sort
-tree sort(from wikipedia, what is it?)

-insertion sort improvement, all suggested by Exercises from TAOCP. 
-insertion sort with linked list
-How does the idea of insert leads to merge sort?
-C++,java, lisp, ASM, TAOCP Pseudo, TAOCP MIX, TAOCP MMIX.
-performance, worst case, average case
-different ways to avoid -INT_MAX as the sentinel. (state of art?)
-non-adaptive version of insertion sort.
-TAOCP Exercises in 5.2.1
-Sedgewick 6.3 Exercises

Selection sort:
-C, perl, python (done)
-C++,java, lisp, ASM
-stable version of selection sort.
-bidirectional version of selection sort.
-comparison with insertion sort.
-comparison with bubble sort
-recursive version of insertion sort
-cycle sort
-heap sort variants
     -tournament sort
     -smoothsort.
-TAOCP Exercise in 5.2.3
-Sedgewick 6.2
-Sedgewick 6.2 Exercise
Binary Insertion sort:
-C (done)
-perl, python, C++, java, lisp, ASM

Bubble sort:
-C (done)
-shaker sort
-perl, python, java, lisp, ASM
-TAOCP 5.2.2

Merge sort:
-C, perl(done)
-python, C++,java, lisp, ASM
-timsort
-performance, worst case, average case 
-Improvements from Sedgewick.
-Non-recursive version or Bottom up version 
-in place mergesort.
-no extra memory implementation (state of art?)
-variations of merge sort. 
-implement merge sort with k list and a k-list merging. 2.4.1.
-TAOCP Exercise in 5.4
-Sedgewick 8 (read - done)
-Sedgewick 8 Exercises.
-Shene's 5-9 Exercises. 
-where can I find problems which apply merging? 
  -Implement CLRS 2.3-7 using merging
  -like to calculate number of inversions.

Linear search:
-C, MIXAL (done)
-perl, python, C++,java, lisp, ASM
-TAOCP 6.1 and exercises.  Remember, it's not as trivial as you may think. 

Binary search: 
-C (done)
-perl, python, C++,java, lisp, ASM
-At least 100 problems which applies binary search.
   -TopCoder's exercises on binary search. 
   -Implement CLRS 2.3-7.
   -Shene Chapter 4. 
-After reading Gries, make sure you prove your own binary search is correct. 
-TAOCP 6.2 and exercies. 
-Chapter 4 and 5 of Programming Pearl exercises. 
-Sedgewick 12.4
-Fibonacci search
-Range search
-Variations of binary search. 
-Thinking: variations of binary search.  They produce different lo, up bounds. Interesting. 
-Thinking: can we combine the idea of distribution in binary search?
-Thinking: what happens if binary search is applied to a sequence with N inversions?

Inversions:
-Try to understand TAOCP 5.1 as much as I can. 

-Try to do exercises in TAOCP 5.1. 

Reread TAOCP 1.1 and 1.2 Algorithms and Mathematical Preliminaries

I reread the first half on Chapter 1. i.e. Chapter1.1 and Chapter1.2.  Unlike 8 years ago, the understanding comes very easily.  I am able to understand all sections without too much difficulty.

This read makes me think :  it's always better to read Math when there are some applications.   I heard about gamma function and Bernoulli's number back in high school.   At that time, I simply don't understand why we need it except it is part of examination question.   Now, my feeling is - how can I *not* learn them?

Good, let's put all exercises under Lv25 to be material in read 3 of CLRS.  All these topics are related to Chapter 3.  I think I can handle all exercise below Lv25.

Why I failed when I read TAOCP the first time.

Believe it or not, this is actually the second time I read TAOCP seriously.  The first time is when I first came to U.S. (around 8 years ago)  I was motivated by the success of reading "Elementary Number Theory".   I finished all the exercises in the number theory book and felt very ambitious another book.  I thought that I can gain a lot by reading TAOCP after I bought its international edition.

There's nothing wrong with that thinking.   Unfortunately, I made mistakes which many people made,  let me summarize at here.
  • I simply tried to read Chapter 1 too deep.  TAOCP Chapter 1 gives a general introduction of computer science.   This introduction is not gentle.  In a way, it brings the reader to the frontier of each of these basic topics.  (So if you go deep for TAOCP in one section, you are likely to be a deep experts in a field.)   This is too difficult for me (or perhaps for many) to finish. 
  • I was scared by MIX.  This is simply a bias.  At that time I was crazily in love with C and has a lot of prejudice.   I have since changed.  
  • I tried to read other CS text.   Ah, one of my biggest problems, after reading something and have success, I liked to move on and go for breadth, than depth.  Not a good habit for deep subject such as Math and CS. 
  • At that time, I wasn't proficient in basic programming skill.  For example even though I finished a master already, I still have basic misunderstanding why writing good program is a good thing.  Experience is my teacher. 
  • Just like many, I thought TAOCP was meant to be a reference.  (Conform to the 99%, Big mistake.)
  • I only think about algorithmic problem when I need to.  (Conform to the 90%,  Biggest mistake)
Learning from my mistakes, my conclusion is - if I want to get good in algorithm, I need to first stick one and only one book.   Not splashing my effort around. So I don't care how attractive is the content in TAOCP, I will simply keep my pace and read on CLRS.  The way I am doing with CLRS - having 3 pointers of read. Each is deeper than the other is the real way to go.

status 20110524 (c)

-Solved 3.1-8.  Notice the "or" in the definition.  All problems in 3.1 are finished, now it's time to move to 3.2.  I expect to hit some hurdles as some exercises could be quite mathematical.

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-2.1
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, 3.2-{1,2,3,5,6,7}, Part-finished 3.2-8, P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),
Revisit: (af Ch3) P2.1c

status 20110524 (b)

-Solved 3.1-6 and 3.1-7. Nothing much to brag.  The 3.1-7's proof is mildly interesting.

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-1.8
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, all Sec 3.1, 3.2-{1,2,3,5,6,7}, Part-finished 3.2-8, P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),
Revisit: (af Ch3) P2.1c

MIT open courseware.

6.001 Structure and Interpretation of Computer Programs

6.033 Computer System Engineering

There was also an advanced data structure course. 

All of them are pretty interesting.  My weakness has always been system knowledge.  (Ah. I am not such a geek.)  And I would like to be broadened by lisp for long time.  

But anywho, just take a peep. I would probably just go a little bit deeper in the advanced data structure course.  Since one day I would need to go deep in topics such as balanced tree. 

 

status 20110524

-Solved 3.1-5.  Just an exercise of proofing skill.
-Corrected the exact exercise numbers for 2nd editions
-also finished P3-4{a,c,d,e,f} in my head
-recorded what I finished in my head for 3.2 as well.

Things go well.  Progress is also faster than I thought.  Spending hard time in Chapter 2 totally worth it.

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-1.6
Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, all Sec 3.1, 3.2-{1,2,3,5,6,7,8} P3-4{a,c,d,e,f}, 4.5-1, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),
Revisit: (af Ch3) P2.1c

Updated complementary exercises for CLRS 20110524

Chapter 2 General:
-Watch the MIT video if it is only about Ch2. 
-Work out all proofs for the following algorithms
  -insertion sort
  -selection sort
  -bubble sort
  -binary insertion sort
  -merge sort
  -linear search
  -binary search
-Implement 2.3.7, P2.1, Horner's rule in P2.3 and inversion calculation in P2.4.  2.3.7 has two solutions, one is trivial, one is based on merge.  Think them through.
-Read all the solution sets after I finished the first 3 items.
-work out cost analysis similar to P.26 on selection sort, linear search and merge sort (tedious).
Chapter 3 General
-Read the Wikipedia's entries in the big Oh notation, iterative logarithm and all Math related subject.
-Alternative definition of the asymptotic notion. 
-Finish all exercises of Sedgewick Chapter 2.
-TAOCP? Knuth must have talk about Big Oh at a certain point. 
-What is the difference between the definitions of Sedgewick with CLRS?
Insertion sort:
-C, perl, python (done)
-sentinel version of straight insertion sort (done)
-binary search (done, now a separate item)
-binary insertion sort (done, now a separate item)
-recursive version of insertion sort (done)
-start to write a performance driver
-shell sort, how does the decrement business works?

   -Pratt's increments.
   -Sedgewick's increments.
-library sort
-tree sort(from wikipedia, what is it?)

-insertion sort improvement, all suggested by Exercises from TAOCP. 
-insertion sort with linked list
-How does the idea of insert leads to merge sort?
-C++,java, lisp, ASM, TAOCP Pseudo, TAOCP MIX, TAOCP MMIX.
-performance, worst case, average case
-different ways to avoid -INT_MAX as the sentinel. (state of art?)
-non-adaptive version of insertion sort.
-TAOCP Exercises in 5.2.1
-Sedgewick 6.3 Exercises


Selection sort:
-C, perl, python (done)
-C++,java, lisp, ASM
-stable version of selection sort.
-bidirectional version of selection sort.
-comparison with insertion sort.
-comparison with bubble sort
-recursive version of insertion sort
-cycle sort
-heap sort variants
     -tournament sort
     -smoothsort.
-TAOCP Exercise in 5.2.3
-Sedgewick 6.2
-Sedgewick 6.2 Exercise
Binary Insertion sort:
-C (done)
-perl, python, C++, java, lisp, ASM

Bubble sort:
-C (done)
-shaker sort
-perl, python, java, lisp, ASM
-TAOCP 5.2.2

Merge sort:
-C, perl(done)
-python, C++,java, lisp, ASM
-timsort
-performance, worst case, average case 
-Improvements from Sedgewick.
-Non-recursive version or Bottom up version 
-in place mergesort.
-no extra memory implementation (state of art?)
-variations of merge sort. 
-implement merge sort with k list and a k-list merging. 2.4.1.
-TAOCP Exercise in 5.4
-Sedgewick 8 (read - done)
-Sedgewick 8 Exercises.
-Shene's 5-9 Exercises. 
-where can I find problems which apply merging? 
  -Implement CLRS 2.3-7 using merging
  -like to calculate number of inversions.

Linear search:
-C, MIXAL (done)
-perl, python, C++,java, lisp, ASM
-TAOCP 6.1 and exercises.  Remember, it's not as trivial as you may think. 

Binary search: 
-C (done)
-perl, python, C++,java, lisp, ASM
-At least 100 problems which applies binary search.
   -TopCoder's exercises on binary search. 
   -Implement CLRS 2.3-7.
   -Shene Chapter 4. 
-After reading Gries, make sure you prove your own binary search is correct. 
-TAOCP 6.2 and exercies. 
-Chapter 4 and 5 of Programming Pearl exercises. 
-Sedgewick 12.4
-Fibonacci search
-Range search
-Variations of binary search. 
-Thinking: variations of binary search.  They produce different lo, up bounds. Interesting. 
-Thinking: can we combine the idea of distribution in binary search?
-Thinking: what happens if binary search is applied to a sequence with N inversions?

Inversions:
-Try to understand TAOCP 5.1 as much as I can.

Partial Reread TAOCP Chapter 5

I was sick yesterday so I stopped any programming activities for a day.   Feeling refreshed now, I decided to delve into implementation of Shell sort and try to understand the goodies.  As a bonus, I also tried to read through multisets, runs, Young Tableux and involutions.   I am sure each of these topics would leave a mark in my mind in future because all of them are very closed to what I am interested most : number theory, group thory and combinatorial theory.   So I have tried to penetrate 5.1.{2,3,4} and 5.2.1.

All of them are deep stuffs.  I got to admit that in the chapter of multiset (5.1.2) and Young tableux (5.1.4), I had to skip some of the contents.  I might want to reread some preparatory material before I read it again (and I just simply believe that one day I will fully understand all the contents one day. Ha. :) ).

I also start to have some intuitive understanding why the increment problem in shell sort is such a difficult problem.  Once a problem can be related to number theory.  You know that it is one of those deceptively simple problem.  That is why most of the introductory book just simply skip this topic.  As far as I understand from Sedgewick paper, this problem is mostly being attacked by empirical method.

This makes me excited because this is the probably the first period of time which I realize my work can have well-defined open mathematical problem.   In the past, what I saw were mostly emprical problem on improving a system X.  Or to device a probabilistic method to improve System X.  Those are interesting problems and fun to work with at the start.  After a while,  without the guidance of theory, this kind of work will stale and deteoriate to only discussion on performance.  Boredom followed.  One might say theory is very hard to be applied in practice.  I tend to believe though that the focus of research could occasionally drift in a mindless manner.

I also thought about whether I should keep track of my progress on reading TAOCP.  Nah, after I while I think reading one single book is already too tough.  CLRS is substantially easier to start with than TAOCP.  Its exercises are also more guided but one should still start CLRS with probably graduate level of Math to fully appreciate the importance of some Theorems in the book.  So I guess if I can finish the 2nd read, I am an alright programmer.   Let's think about the next step at that point.

What I would do though is that from the point of implementing Shell sort, I will start to also write a driver for all the sorting algorithms.  This is the moment I want to quantitatively understand the characteristics of different sorting algorithms.  Different increments should be examined carefully.  It sounds like it will indeed take me some time to understand insertion sort.....

Speaking of which, it's time to get back to CLRS and do an exercise or two, or reread BST.   Small blocks but it's still take some cognitive load to get through.

Sunday, May 22, 2011

Can CLRS be used as a self-study tool?

Absolutely.

Most of the time I heard people described books such as CLRS, Sedgewick and TAOCP are "reference books".   If you are taking a class in CS, I guess that is an ok thinking.   Though if you are a professional in computer programming, or if you need to change programs in a day-in day-out basis, I will say that CLRS, Sedgeick, TAOCP are completely for reading and for studying.

What confuses most of the people is that reading an algorithm book cannot be a cursory reading.  i.e. what most of the people do most of the time.  Reading an algorithmic book is meant to be as serious as reading a literature.   You want to understand it in many levels.   It can be sentence-by-sentence as you want to understand what the author means.   It can also be an extraction of the semantic of the whole chapter, whole paragraphs.   It can also be an understanding of the whole book. You may also need to read the book by reading many books in a certain subject to get an understanding. 

Or more detail methods on how to read a book, I will suggest everyone to read Alder Mortimer, an Aristotelian's scholar,  "How to read a book".   There are many levels of reading described in his book.  In his description, the ultimate level of reading would be syndicate read.  That is to read many books and collate the combined information and gain a higher understanding.

When, many of us read, we basically subscribe to tenet of speed-reading in which we parse the text from left-to-right, wraparound and repeat as fast as possible.   There is a place for speed-reading but books are not meant to be read in this way. 

Algorithmic book has another requirement if you want to get something out of it.   You need to read it with a computer and pieces of papers.

You need a computer because it is crucial to implement the algorithm to a certain extent to attain understanding of an algorithm.   You may find that the algorithm described is wrong.  That happens to books which are written by famous writers.   You may find that you can do better and think of many variations of the algorithms.    This will be prominent when you look up several algorithmic books.   For example, there is not description of bottom up merge sort in CLRS, but there is one in Sedgewick.   It's a useful skill to learn how to convert a recursive algorithm to an iterative one.   So, learning both certainly don't hurt. 

You also need papers because there are a lot of Math in algorithmic study.  You want to understand a proof by possibly write it own.   You want to think of variations of the proof.  You want to extend the proof to a more general proof.  (even if it is something you consider it as meaningless at the time.)  Of course, you want to do exercises for the simpler books. 

In fact, when you listen to very good programmers, you will find that they are always drilling on great algorithmic books.   They know all the ins and outs of some simple algorithm.    And if you listen to great mathematicians, they will tell you the best way to learn a subject is to try to prove all the theorems of a good standard text book on the field. 

Everyone can be benefited from this way of learning.  It is just a matter of a person's devotion, persistence and patience of the subject.

Reading Math and CS books

Almost always, studying a chapter of a Math and Science book  worth 1000 times than browsing it through.   So if it takes you a day to read through a chapter but 50 days to finish all the exercises and think deep,  consider it as a bargain.

status 20110522

Solved 3.1-3, 3.1-4.   3.1-3 makes you think because in your respective field, there got to be some people who abuse the O notation.

Also finished exercises 4.3.{1-3} for 2nd edition in my head.  I have both 2nd and 3rd editions. I put the 3rd in the office.   So I don't know which exercises I have actually done - In 2nd edition, Chapter 4 was not first started by introducing the maximum subarray problem.   It goes straight to solving recurrence.

BTW, solving recurrence is super important.  I might want to follow this chapter up by reading "Concrete Mathematics" as well.

Fuzzy reading: 339/1144
Browse reading: 309/1144
Exercises up to 3-1.5 Exercises which are finished but not on paper: 1.1-2, 1.2-2, 1.2-3, P1-1, all Sec 3.1, 3.2-2, 3.2-6, 3.2-7, (2nd Ed.) 4.3-{1-3}, P4.4(a-c), 6.1-{1,2,3,7}, 6.2-3, 6.2-4, 10.1-6, 10.1-7, 12.1-{1,2,4} 12.2-{2.3}, 12.4-4, P12.4(a),
Revisit: (af Ch3) P2.1c

Zen and the Art of Motorcycle Maintenance (Part 4)

Finished another 40 pages of the book.   This is one of the most thought-provoking book I have ever read because it touches so many philosophical issues which a programmer/scientist should think deeply.   I start to follow the core of the argument.  i.e. what quality is.   I cannot overstate the importance of this topic to programmers.    Because all of us know we sometimes just encounter code which is good beyond description.  The extent of this problem is multi-level, it could be as small as whether

if(a>0) printf("%d\n",a);
else printf("%d\n",b);

is "better" than
if(a>0)
    printf("%d\n",a);
else
    printf("%d\n",b);

Or how should we add a new feature in big program written by object oriented programming.  (Think again if you think that there is only one way.)

Or why would we think that in a certain situation, nl is better than perl -lane '{print "$.  $_\n"}' or why are they are not as good as writing a separate perl script in others?  (Again, if you think only the command is better or if you think writing a perl script is better, you better think again.)

Or is it more correct to write a correct program with fewest number of lines? fewest number of characters? or it should be written with full commentary? or should we also give test cases?

Of course, this is just a very narrow aspect of "quality" which is discussed by Prisig.   His discussion of quality, though started from rhetorics are highly relevant to all skill-related works.   One can ask with similar rigor,  what is quality of cooking? what is quality of writing? what is quality of proofing?  what is quality of painting?  what is the quality of acting?  Those are among the most difficult questions which for the most time there is no satisfactory answers.

Saturday, May 21, 2011

Zen and the Art of Motorcycle Maintenance (Part 3)

Finished another 20 pages.  I cannot agree more.  The lines are for a mechanic but we can all see why we all fit in.  That's also why we want to self study.

"His creative intelligence, stifled by too much theory and too many grades in college, would now become awakened by the boredom of the shop.  Thousands of hours of frustrating mechanical problem would have him more interested in mechanical design.  He would like to design machinery himself. He'd think he could do a better job. He would try modifying few engines, meet with success, look for more success, but feel blocked because he didn't have the theoretical information.  He would discover that when before he felt stupid because of his lack of interest in theoretical information, he'd now find a brand of theoretical information which he'd have a lot of respect for, namely, mechanical engineering."

"So he would come back to our degreeless and gradeless school, but with a difference.  He'd no longer be a grade-motivated person.  He'd be a knowledge-motivated person.  He would need no external pushing to learn.  His push would come from inside.  He'd be a free man. He wouldn't need a lot of discipline to shape him up......."

Word.

Tiger moms,  read this.  You are darn wrong.  This is how human, and most importantly children should learn. 

Random Thought

The best anecdote for programmer's frustration is Mathematics and Algorithm Study.   Math is ultimately how everything works.



Algorithm Study can be as elegant.  It just takes some time and more practice to see how it is and why it is.

Red-Black Tree

I have been thinking how come red-black tree's algorithm is so difficult for me to absorb.  Part of it is that RB tree by itself is not a perfect design (as mentioned by one of the original inventors, Sedgewick).  Part of it is that understanding RBT requires one to understand BST to a certain extent.   One will not understand how the deletion of RBT works if he doesn't understand how deletion of BST works.

In conclusion, let's reread Chapter 12.

Blogging as a study tool

As it turns out, blogging is actually a pretty good kind of journal.  First of all, it has all the advantages of hyper text such that I don't need to flip around my notebook when I try to look up my previous answers or notes. 

It's also a good place to rant to express oneself.   Who cares whether people like your posts or not?  You have quite a bit liberty to control issues like this.   Writing all these small issue down all the time can be too tedious for a written notebook.

Anyway, as I started Chapter 3, it becomes my goal to finish it.  Let's see how it goes.