By Kardi Teknomo, PhD.

Analysis of Algorithm

Share this: Google+
< Contents | Previous | Next >

Say you make a computer code (in any programming languages of your preference) and when you run your code, it takes about 1 minute per run. “Not so bad”, you said, considering you have spent hours of programming it and considering if you do the computation manually, it will take hours or even days.

Now that you have the computer program to automate your task, then a new horizon come up. Suddenly you feel empowered to run the same program to analyze more data.

You know that for your laptop capability to loop over say 10,000 an empty module is less than a second. You also know that one run of your program for one piece of data is about 1 minutes. Now you are eager to use your computer program to analyze 10,000 data. How long do you think your computer will run? “May be in a few hours”, you may think. “I can run it overnight and in the morning it should be done”. Then you add a few line of code to read the data and start to run for 10,000 data having nice sleep and expecting the computer will give you the result in the morning.

When you wake up, the laptop computer is still running and no results yet. To make the matter worse, the running of this program actually make your computer to become very slow because your computer program eat up a lot of your computer memory. That means you cannot use your computer for other purposes. “Okay, I will not use the computer today and I have many other things to do without computer anyway”, you said.

Evening come and the computer is still running. “May be tomorrow morning it will finish”, you said. The next morning come, it is still the same. After three days running you start wondering when it will finish. You start to put out your calculator and compute the estimate of the running time of your computer program:

1 minutes * 10,000 runs / 60 minutes/hour / 24 hours/day = 6.94 days

“Oh, if I were to compute this before I run the program, I should have used my other desktop that I did not use for normal work”. Now that you have already run it a half way, you start to wonder whether to terminate the running of your program and wasted 3.5 days of computer run, or to let it run for another 3.5 days and suffer because you cannot use your laptop. “I should have save the results of every run such that in case I need to stop it, I do not need to restart from the beginning again.”

The above story is one of the very typical stories on how programmers are often so ignorance about the analysis of algorithm. In this short tutorial, you will be introduced to the important of analysis of algorithm and how you can read the meaning of computer jargon such as O(n^2) or O(log n). The purpose of this tutorial is to motivate or to whet your appetite to learn more about analysis of algorithm.

Let’s begin.

< Contents | Previous | Next >

Share and save this tutorial
Add to: Del.icio.us Add to: Digg Add to: StumbleUpon Add to: Reddit Add to: Slashdot Add to: Technorati Add to: Netscape Add to: Newsvine Add to: Mr. Wong Add to: Webnews Add to: Folkd Add to: Yigg Add to: Linkarena Add to: Simpy Add to: Furl Add to: Yahoo Add to: Google Add to: Blinklist Add to: Blogmarks Add to: Diigo Add to: Blinkbits Add to: Ma.Gnolia Information

These tutorial is copyrighted .

How to cite this tutorial:

Teknomo, Kardi. (2017) Analysis of Algorithm .
http://people.revoledu.com/kardi/tutorial/Algorithm/