Shortcut for chapter specific information

Showing posts with label daily practice. Show all posts
Showing posts with label daily practice. Show all posts

Wednesday, June 15, 2011

Daily Practice 20110615(a)

Insertion Sort 76            (C): Good
Insertion Sort w Sentinel 16 (C): Good
Selection Sort 36            (C): Good
Merge Sort 19                (C): Bad
Linear Search 9              (C): Bad
Binary Search 8              (C): Bad
 
Implement the first 6 algorithms for daily practice and it last for about an hour. After merge sort, I start to lose my focus and simple things such as linear search and binary search starts to feel tough. So I need one-off debug.  

My weakness is still on C-level syntax.  It worths the time to brush it up.  But in terms of algorithm I think I still fully grok the 6. 

Here are the two tougher ones which are bubble sort and binary_insertion_sort.  Bubble sort is easy to implement but I always mix it up with insertion sort.  Whereas binary insertion sort is plain right to complicated to implement. 

Let's split them into the second half.  Then I will also work out 4-1.3 on route.
 

Before 4.1-3

Since I haven't implemented for a while (for leisure, a month?), the blurry feeling of programming comes again

This is the moment one should not feel ashamed.  Everyone can forget something who has done.  So I decide to go back to the daily exercises and see if I can finish them now.  (or how bad I am?)

Friday, May 20, 2011

Daily Practice 20110520

Insertion Sort 75            (C): Bad
Insertion Sort w Sentinel 15 (C): Good
Bubble Sort 3                (C): Good
Selection Sort 35            (C): Good
Merge Sort 18                (C): Good
Linear Search 8              (C): Bad
Binary Search 7              (C): Bad
Binary Insertion Sort 6      (C): Bad
 
Need one off debug - mostly, missed a variables here and there.  Strangely, I can't remember Bubble sort and binary insertion sort.  But it seems like the proof of Bubble sort and structure of insertion sort help me to remember on how things work. 

Starting from this practice, I will also skip the rule of rewriting the same program again.  It will just take too much time.

Tuesday, May 17, 2011

Daily Practice 20110512

Insertion Sort 71 (C): Good
Insertion Sort w Sentinel 11 (C): Bad
Insertion Sort w Sentinel 12 (C): Good
Selection Sort 32 (C): Good
Merge Sort 13 (C): Good
Linear Search 6 (C): Good
 
ISwS dies because I switched the statement k=A[j] in at line 8.  


I need to get back to a stage where all implementations are good.  Probably it won't be easy because by the end of chapter 2.  I need to implement 4 more algorithms.
 
In any case I found that this is a great exercise because it sharpens my mind and make me focus.

Saturday, May 14, 2011

Daily Practice 20110514

Insertion Sort 73            (C): Bad
Insertion Sort 74            (C): Good
Insertion Sort w Sentinel 14 (C): Good
Bubble Sort 2                (C): Bad
Selection Sort 34            (C): Good
Merge Sort 16                (C): Bad
Merge Sort 17                (C): Bad
Linear Search 7              (C): Bad
Binary Search 6              (C): Bad
Binary Insertion Sort 5      (C): Bad
There were many one-off mistakes.  For now, I also feel it is a bit beyond my cognitive load to write 8 algorithms a day.  The feeling of knowing how they work is great.  Though I think I should slow down before I introduce the 9th algorithm into the set.  Let's reduce the amount of errors first. Preferably 0 per day.

To save time, I'll also skip the requirement of rewriting.  Because the cost of a single mistake is too high.  Though, I will force myself to check the code 3+ times in my head from now on.

Friday, May 13, 2011

Daily Practice 20110513

Insertion Sort 72 (C): Good
Insertion Sort w Sentinel 13 (C): Good
Selection Sort 32 (C): Bad
Selection Sort 33 (C): Good
Merge Sort 14 (C): Bad
Merge Sort 15 (C): Good
Linear Search 7 (C): Good 
Binary Search 5 (C): Good

SS32 fails because imin was misspelled as min. 
MS14 fails because k wasn't initialized correctly in the merge function.

Daily Practice 20110512 (Thursday)

Insertion Sort 71 (C): Good
Insertion Sort w Sentinel 11 (C): Bad 
Insertion Sort w Sentinel 12 (C): Good
Selection Sort 32 (C): Good
Merge Sort 13 (C): Good
Linear Search 6 (C): Good

Back-record: I failed at ISS again. Record is lost.  But I vaguely remember is because I switch k=A[j] to j=A[k] at line 8.

Daily Practice 20110511 (Wesnesday)

Insertion Sort 70 (C): Good
Insertion Sort w Sentinel 9 (C): Bad 
Insertion Sort w Sentinel 10 (C): Good
Selection Sort 31 (C): Good
Merge Sort 11 (C): Bad
Merge Sort 12 (C): Bad
Linear Search 5 (C): No Practice

Back-record: Can't remember any more why I failed ISS9 and FS11. I remember though I was watching NBA playoff so my concentration is greatly deteoriated.

Tuesday, May 10, 2011

Daily Practice 20110510

Insertion Sort 69 (C): Good
Insertion Sort w Sentinel 8 (C): Good
Selection Sort 30 (C): Good
Merge Sort 10 (C): Good
Linear Search 2-4 (C): Bad 
Linear Search 5 (C): Good

I am happy that all sortings are good. But I am curious of why linear search took me couple of time to get to exactly what I want.  I think the reason is I don't actually have a feeling of what the output should look like. (Mistake in LS 2 and 4.)  Also, classic mistake of using the wrong array in function also occurred (in LS 3).

Monday, May 9, 2011

Daily Practice 20110509

Insertion Sort 67 (C): Bad
Insertion Sort 68 (C): Good
Insertion Sort w Sentinel 7 (C): Good
Selection Sort 29 (C): Good
Merge Sort 9 (C): Bad 
Merge Sort 10 (C): Good
Not in my status. IS67 is bad because I used > rather than >= in the inner loop. MS9 is bad because I included <strings.h> instead of <string.h> in the library.  So the code doesn't compile correctly.

Friday, May 6, 2011

Daily Practice 20110506

Insertion Sort 66 (C): Good
Insertion Sort w Sentinel 6 (C): Good
Selection Sort 28 (C): Good
Merge Sort 7 (C): Bad 
Merge Sort 8 (C): Good

MS 7 is bad because I used the array as the working memory. ah.

Thursday, May 5, 2011

Daily Practice 20110505

Insertion Sort 65 (C): Good
Insertion Sort w Sentinel 5 (C): Good
Selection Sort 27 (C): Good
Merge Sort 6 (C): Good

Got the merge sort right one shot.  How excited I am!

Wednesday, May 4, 2011

Daily Practice 20110504b

Insertion Sort 64 (C): Good
Insertion Sort w Sentinel 4 (C): Good
Selection Sort 26 (C): Good