Showing posts from January, 2015

Merge Sort explained

Merge Sort is cool because it's one of the best sorting algorithms in terms of O(N) and time complexity. It's O(n log n) for worst case! (Bubble sort and the like are O(n^2) for worst).
The recursive version was pretty intimidating for me when I first looked at it, but after practicing it a couple times, it became easier.

If you read some literature on Merge Sort, you will see that they talk about "chopping up an array into element size 1 arrays" and then merging them back together. This sounds really weird but recursively, the syntax becomes very clean.

So first of all, we have the "mergeSort" function that takes in an array and chops it up like we said. This is the function that we will call ultimately.

Then we have another function called "merge" that gets called inside this mergeSort function. This merge function is the one doing the sorting, compare two different arrays, seeing if the first index of A is less than first index of B and then merg…

SyntaxHighlighter yay

Figured out how to use SyntaxHighlighter for making code snippets into this below format for Blogger. Googling should do the trick if you are looking to know how, but going into the Template HTML for Blogger was needed, just some quick copy and paste. 

And then you specify the class in your pre tags in your HTML mode. The class attribute of pre can be "brush:java" or "brush:ruby" ... etc.


void hi() {

Interview Preparation Time

It's been hectic trying to prepare for one interview after the other.

I take it day by day trying to tackle one new topic a day: linked lists, time complexity, merge sort, insertion sort, bubble sort, BST, traversals, algorithms, recursion, stacks/heap, memory management, OS, SSL, stacks/queues ... Since the new year, it's been basically a non-stop cramming session.

I'm very grateful that companies are taking an interest in me, but interviews are really a different beast than building actual apps, so it hasn't been easy. They are fun in their own way though. Figuring out and understanding an algorithm (or terms like "stack" or 'heap") that used to intimidate the crap out of you is a great feeling.

It's very weird how interviews themselves don't really focus on "what you can build" using your iOS knowledge and application skills, but rather they test you on these esoteric concepts. Will we be using these concepts in our day-to-day at wo…