## Wednesday, May 9, 2007

### Why algorithm or algo ?

I am quite interested in figuring out the patterns and algorithms behind a solution or a process .

Fundamentally believe that for many things, there is a method .
The expert ( experienced, master, talented ) uses the method consciously or tacitly . The person at the beginner or intermediate level is awed by the knowledge in initial stages and later strives to get to the method .

The person who cracks the algo rises above the extra-ordinary . He will be on a firm ground
to tackle the future challenges. To become a better person , I have this eternal quest for " algo" and which is a key driver for my writings.

To demonstrate the power of algo, consider the below example.

If x = 3 to power of 22 and y = 6 to power of 65, what is the remainder when xy is divided by 10?

To a layman, the above question might be tough inspite of having good maths background.

Whereas, the trained mind can observe and generalize a pattern .

Solution :
6 to power of anything always ends in 6.
3 to power of anything has a pattern - the numbers end in 3, 9, 7, 1,
So multiplication of units in both x and y result in a pattern - the unit digits of results will be cyclic - 8, 4, 2, 6 .

With the knowledge of basic maths , but more importantly figuring out the Pattern, this problem can be solved in a minute.

Consider the repertoire of skills required in different categories

1. Intelligence tests
- mathematical , verbal, spatial, logic, pattern recognition, visualization, classification

2. Creative
As per Edward De Bono , the Guru of creative thinking, we could add more to the list -
lateral thinking, out of box thinking , innovation etc.

3. Professional
- Planning , communication, execution , analysis, time management, inter personal skills etc.

One could summarise the above in two words - Analysis and Execution.

Here the word analysis is a on a broader level like understanding , but also spans the concepts of synthesis , innovation etc. What about spiritual , emotional intelligence, value system?
The word "analysis " falls short .

Hence we could say - Mind and Action.

Most of the things are being done by our mind and by our body .
By "Action" , we could include things of physical aspects - eye-hand coordination, reflexes, verbal communication, fitness , sports intelligence etc.

With this simplification(synthesis or summation) algo , there are only 2 things to consider .

Having said that, let's explore how the different algos can be used from now on in both mind and action domains.

For now , a small snippet in mind domain.

Consider the challenges faced by a Java Architect and a Retail (Deli/grocery) shop keeper .
Both of them have to address space limitations and seek optimizations.

One is concerned about the design of how to get large Objects to realization only when they are needed. ( Uses Lazy instantiation).

The other orders the stock just before the inventory levels are down or when there is a near future demand ( festival etc).

The algo used both by experienced techie and by the average Joe is " get it when you need it or else it's redundant and causes overhead " .

There are many such similarities in business and in technology . The underlying algos remain same .

And that's interesting ..

yoglok said...

Sam

i highly recommend that you purchase and read the following books.

1. Godel, Escher, Bach
2. Metamagical Themas

Rejeev Divakaran said...

Ability to comprehend algorithm is one difference between living and non-living (I don't think it is unique to human though). However there are problems which cannot be solved by algorithm.

Sam said...

Rejeev,

Say if I write an article " why should you travel by flight " .
Does it mean that I am discouraging to travel by train? I am not saying " why should you travlel by flight only" :)

The idea was not to solve new problems by searching/formulating an algorithm. But to figure out the pattern after you have solved the problem, so that next time you are a better person. If everything was solved by an algo then there is no place for discovery and invention.
I am not advocating that algo is the only solution.
Some problems are solved by creative intelligence ( innovation) and dynamic decision making.

Let me give you an analogy of mine which I call it as " Jungle intelligence "

You could go start hiking in a jungle/forest with a map. The Map is sort of an algo.

But you should not blindly assume that the map actually reflects the terrain. Due to new changes like rain/landlides or a new bridge the terrain presents new challenges and opportunities. The human mind
can instantly decide to drop the algo and figure out an alternate route based on the latest changes.
For example, instead of land route, one might decide to swim and take a new water route.

Thats the difference between the human and computer . Computers are stuck up with algos and then can act on information only if they know what to do about it. They cannot understand new information.

Take one more example - while hiking we come across umpteen number of challenges in terms of encounters with animals that we never we saw earlier.

So we drop the algo and run for life right :). But next time you will be well prepared .

That preparation and anticipation of challenges are sort of algo - Next time you would have studied ..as what kind of animals are present, and where and what time. How do you avoid/tackle them if you run into them. You might carry a gun to scare thyem . All these preparation and pattern realizations are elements of algo. If we don't understand the pattern and do not prepare then everytime we will be a novice and run.