Monday, January 11

Algorithms, Ted Talk, Life

I spent some time today learning about Algorithms. I thought of taking the MIT opencourse ware lectures in passing and now I find them very interesting. I wished such resources were available during my engineering days. It was fun learning about Asymptotic Notations, Sorting algorithms like Insertion sort and Merge Sort. I still need to revise them, however I feel good that I took one step.

Insertion Sort is a simple sorting algorithm, that sorts an array one element at a time. It is less efficient on a large array list however it has several advantages.
1) Very simple implementation
2) Very efficient on small data sets
3) It is Adaptive, i.e it is efficient for data sets that are already sorted. The time complexity is O(nk) when each element in the input is no more that K places from its sorted position.
4) It requires only a constant amount O(1) of additional memory space.

Insertion sort iterates consuming one input element in each repetition. It takes out one element, places it in its correct position and repeats until no element is left. Sorting is typical done in place. At each array position, it checks the value there against the largest value in the sorted list, if larger it leaves the element in place and moves to next.

The best case for insertion sort would be when the array is already sorted. In this case the insertion sort has a liner running time i.e O(n).

The simplest worst case would be when the array is sorted in reverse order. The scenario gives insertion sort a quadratic running time of O(n^2)

The average case would be when sorting a large data set.

for i = 1 to length (A) - 1

   x = A[i];
   j = j - 1;
     while j >= 0  and A[j] > x
         A[j+1] = A[j];
         j = j - 1;
     end while
   
     A[j+1] = x;

end for

==================================================================

Apart from learning, I also spent some time on watching youtube videos about Ted talks. I am a huge fan of such videos. I watched the talk given by Tia Lopez about how to read everyday. It was basically about how to improve our lives by improving and working on our health and wealth. He had a very good point about being successful in life. Having a mentor, how important it is and why you should have one. I have read quite a few articles on mentorship, and totally agree to what Tia had to say. I have planned to seek mentorship from one of our most intelligent and smart UX lead at work. She has very amazing soft skills and she is very very good in a debate. I appreciate her communication skills and this days, everyone has to be a people's person instead of being just a quite, simple and ignorant developer. You can watch the ted talk here

==================================================================

Life is pretty simple, I had some ups and downs and I strongly believe that I am a person who will make sure he does not get faced with a problem which he thinks will cause a minutely tiny unnoticeable quake in his life. Yes, that is true about me, I always run away from problems. I am working on this weakness, however, all in all, today was quite a pleasant day. I woke up late, so it was decided that I would be skipping gym, however, thanks to my gym buddy, I went and hit some weights.

To end this blog post, I wish to quote warren buffett,
"Someone is sitting in the shade today because someone planted a tree a long time ago." - Warren Buffett.


Be the first one to Comment!!!

Post a Comment