## Insertion Sort on A Glance

My first encounter on my journey to re-learn algorithm is the insertion sort algorithm. This the code that I took from TADM book:

And this is the illustration that I took from the net:

Insertion Sort

From the code and the illustration, you can see the characteristics of insertion sort are:
1. Start from index 1. Why? Because if the list length is 1 then there is no point to sort it.
2. There are 2 loops. One for iterating the list and the other for comparing the current index with the item on the behind. The second loop only keeps iterating if the current item is lower than the item behind.
3. Swapping. When comparing backward, the lower item will be swapped with the higher item. So this swapping needs an array to be fast.

## To log(n)

I’ve stumbled upon this site . It contains a list of competency for programmer, from the basic and to the expert. Reading on the list, I mostly on Level 2 or n (this is a term used in analysis of algorithm) even though several sections put me on Level 3 on also on Level 1. But I want to be conservative when looking at my own knowledge and skills so I decided to see myself as still in Level 2 (on average) and I am planning to improve my self on the section that I am lacking of. I want to reach Level 3. The Log(n), that might be the fastest algorithm on the planet because if you put 3,000,000 that it equals to  6.47712125.

Currently, I am focusing on improving my algorithm knowledge so I decided to re-learn the Algorithm and Data Structures subject that I’ve learned on my college. After a small research, I came up with The Algorithm Design Manual as the best book for learning Algorithms.

Also, I decided to log my journey on this trip to log(n) and beyond!

## Using Objective-C in NDS Development

Well, I finally got the time to get my hands dirty on looking for ways to using one of my favorite programming language, that is Objective-C in NDS Development. Recently, I changed my path from the previously doing enterprise applications using C# into the world of iPhone development using Objective-C. I was freaked out the first time I try the Objective-C language and the tools involved. Everything looked different! The tools behave unfriendly, especially the debugger…Oh my god! No, graphical and intuitive ways to look into variables, especially arrays and collections. I was thinking I was entering a primitive civilization!

After, several weeks using it! Hmm…I am beginning to like it! I feel very easy to do modification or changes in classes that I’ve written. Every methods is virtual by nature in Objective-C, the Protocols, Categories, Notifications, its feels like I am programming using a scripting language. Also, the Cocoa! Its amazing! It’s very easy to do user interface especially animations. And interface builder, I LOVE IT! It just provided what I really needs.

When, I was trying to compile my first NDS program. I was thinking, it must be good to have Objective-C in NDS Development. I don’t know wether it was possible. I tried to wrote a simple Objective-C class then I compiled it using devkitARM. It was successful to produce the object file but the linker was complaint! The linker said it cannot found the Objective-C runtime. I tried to modify the linker rules file and no luck. I’ve tried Googling but I found no references. I’ve tried asking in devkitPro.org forum but no one answer! It was seemed no hope!

I just leave it be until the next week I tried it again. This time I tried to find command arguments of the linker. Because, devkitARM is using the arm-eabi compiler from Sourcery that is based on GCC then the Objective-C compiler is already there. I already proved that it can compiled Objective-C file. I just need to find a way to link it using the linker. It turns out that I just need to add one additional command line arguments to include the Objective-C runtime. And then, it successfully compiled and linking my Objective-C program. I’ve tried to instruct it to draw a pixel and a diagonal line to the screen and I was very happy to finally see the pixel and the line drawn on the screen. I’ve done it using Objective-C!

Ooh! What a relief!

The journey, just begun!

Posted in NDS, Objective-C | 2 Comments