Tuesday, November 26, 2013

Introduction to algorithms

This is the first article in my series on algorithms. Hopefully this would be helpful to someone.

What is an algorithm?
The word algorithm comes from a persian author Abu Jafar Mohammed ibn Musa al Khowarizmi. It is formally defined as : "An algorithm typically refers to a set of instructions that can be executed by a computer to produce the desired result" or "An algorithm is any well defined computation procedure that takes some value or set of values as output".

What are the properties of algorithms?
According to D.E.Knuth a pioneer in the computer science discipline an algorithm must have the following five properties:

a) Input : An algorithm has zero or more inputs, which are given to it initially either before it begins operation or dynamically as the algorithm runs. Input refers to data that is supplied to the algorithm on which the computation is performed.

b) Output : An algorithm has one or more outputs that have a specified relation to the inputs.

c) Definiteness : Each step of an algorithm must be precisely defined. Meaning that the actions to be carried out must be rigorously and umambiguosly specified for each case. Operations such as "compute 5/0" are not permitted because it is not clear what the result is.

d) Finiteness : The algorithm must terminate after a finite number of steps.

e) Effectiveness :  An algorithm must also be effective. This means that the operations must be sufficiently basic so that in principle anybody can do them using a pencil and paper. Performing arithemetic on integers is an example of an effective operation but the same is not true for performing arithemetic on real numbers.

Friday, July 5, 2013

Never lose your changes

One problem most of us have faced while developing software projects or even simple programs is breaking the entire program while trying to fix a program with some errors. So instead of fixing the few errors that we had initially we end up breaking the entire program itself.

It gets worse if you don't remember what changes you made to the file. This would generally mean that you would have to start from scratch again. When creating big projects this could mean disaster. People realized that this could be a huge problem and came up with something known as VCS. VCS stands for version control system. Though there are many vcs available like subversion, in this article we will primarily be focusing on Git.

Git is a version control system quite different from others. While other vcs systems remember the differences or modifications you make to a file, Git records different versions of your files as snapshots.
And if there are no modifications made to the file, it stores the snapshot as a reference(point) to the older version.

There are three states in Git: Repository, Staging area, Working directory.

The way it works is: You take a file from the working directory and push it to the staging area and make modifications. The staging area means that the files have been modified but not yet committed. You need to commit the files to let Git save the changes made to the file. At any time in the future if you feel that the you need to go back to the previous versions you can simply rollback the commits to go back to the version you deem is stable for your use.

Git is also a distributed vcs. This means that many users can collaborate on projects and work on the same files without the fear of over-writing each others work as the Git framework lets you have a snapshot of all the versions of the files.

To know more about Git, you can read from this free online book : Git Basics

The best way to work with git is using github.

Also many hiring managers from the silicon valley have said that a good github account gives them a lot of insight into a student, more than his mark sheets ever can.