Wednesday, September 17, 2008

cheer up bro

Going back home from office with the realization there's no one at home is becoming increasingly tough for me. I wonder how I managed it for the past one and a half month. And I don't even want to think about the fact that I have 4 more months (minimum ... that is ...) to spend this way.

In India, it's a norm that the pregnant wife will spend her last 3,4 months of pregnancy and the first 3,4 months of motherhood at her parent's place. And it's a widely agreed school of thought, that the husband's feelings during that period must be like .... wow .... !! yuuuhuuuu .... !!! But, no ... not me. I got too habituated to the comfort of having some one to speak to (back home) to bear with the thought of having to spend about 12 hours all by myself everyday.

Here are some interesting techniques and skills I have painstakingly developed over months after marriage:
1) I can code for fixing an intricately involved bug even as I listen to home news bulletin from my wife.
2) I can actually repeat the news bulletin - word to word - in case my wife tends to think I'm not paying attention. (Later I also remember giving her a choice of listening to a short summary - 2 marks or a detailed discourse - 10 Marks)
(Actually I'm mid-way - developing a technique where I can repeat what she said - word-word in the reverse order, not that it interests her .... just very amusing ..)
3) With a single look (I needn't even have to hold them), I can differentiate between capsicum and a badly grown brinjal.
4) I can prepare these items (ordered in ascending order of expertise) - coffee, horlicks, maggie noodles.
5) I can carry about 7 kg of grocery on each of my hands and walk slowly (to match my wife's pace) with an unfading smile on my face in a heavily crowded market area. (Normal people will have to do specialized yoga to achieve this feat.)
6) It's only after marriage that I couped up enough courage to watch a full telugu movie. (A piece of cake for my wife :( )

Don't want to boast about it in the list of points above, but I'd want to mention here - in passing - that at one instance, I bravely argued with an auto-guy for a rupee (only once though).

And it all seems such a waste, that I have no one to whom I can show-off these skills.

But, just as things were turning worse from bad, a ray of hope entered my life this evening, in the form of a dog. Okay, don't get confused. I can explain.

This evening, as I had a few things to purchase from Nilgiris, I had been there and was coming back with a fairly big carry-bag in my hand. Here I was walking, and at about 25 meters from me, due north east, I happened to glimpse at a dog on the other side of the road. Even though some people will be skeptical on this, I happened to easily observe that the dog's eyes were on my bag. I wanted to avoid a scene. So I started walking faster and realized that the dog was doing same on the other side. The road was fairly well occupied with zooming vehicles, so everything is fine for the present. My razor sharp brain could immediately come up with 2 plans, as they show in the movies - plan A and plan B. At this point, the road became silent because of a signal further down, and as anticipated, the dog crossed the road to my side at about 43 kmph. I don't understand dogs, especially this one. I guess it thought that I was a pie-faced nincompoop or something. It was about to know that it misjudged me. We were separated by about 15 meters and it starting walkin towards me, it's eyes hawk-like on the bag. Distance between us slowly started reducing. (slowly - owing to the facts that i) I wasn't too keen to get near the dog and ii) the dog was stalking it's prey.). We are about 7 meters apart, when I stopped on my tracks. The dog stopped as well. I had plan A on the cards. So, I lifted my bag up over my shoulders. Our eyes briefly met. I mustered up as much malice into my eyes as possible. But the dog looked away indifferently, back at the carry-bag. I delivered plan B. I took out the umbrella that I had hidden in the carry-bag and walked towards it (the dog, I mean) in quick steps with it (the umbrella) uplifted in a threatening manner. I think it understood the general message I wanted to convey - about how superior I was. It immediately backed out and ran away to it's evening chores (which I'm sure involves - conversing with it's friends about the incident, picking at humbler targets etc).

I came back home thinking that life isn't that bad after all.

Sunday, August 03, 2008

Number of company mergers - explanation rather than proof

One of the famous problems in combinatorics that interests a comp.sci. enthusiast - is the Catalan's problem - that talks about finding the number of binary bracketings of n elements. For example, if we consider three elements 1, 2 and 3. We have :

((1 2)3)
(1(2 3))

as the binary brackets, in that order of 1,2 and 3. If we consider 4 elements, say, 1, 2, 3 and 4. The number of binary brackets in that order is 5 - and they are:

(((1 2) 3)4)
((1 (2 3))4)
((1 2)(3 4))
(1((2 3) 4))
(1(2 (3 4)))

Imagine 1,2,3 and 4 to be 4 elements held in the computer memory. In the above example, we have fixed order of retrieval of the elements, i.e 1,2,3 and 4.

Catalan has proved that this number is given by the formula:
C(n-1) = 1/n * (2n-2 C n-1) , where (n C k) is n choose k - or the kth binomial co-efficient.

It is easy to see that, this number also exactly gives the number of un-ordered full-binary trees of n-leaves (or n-1 internal nodes).

o 0 0 0 0 0 0
/ \ / \ / \ / \ / \ / \ / \
0 3 1 0 0 4 0 4 0 0 1 0 1 0
/ \ / \ / \ / \ / \ / \ / \ / \
1 2 2 3 0 3 1 0 1 2 3 4 0 4 2 0
/ \ / \ / \ / \
1 2 2 3 2 3 3 4

Leaving this at that, let's look at a related interesting problem of counting various possible ways to merge N companies. This is related to the above problem because, in essence we are counting binary bracketings of companies. But here, the differnce is that, order matters. Since there are N companies - the merger process can be viewed as a full binary tree with N leaves. The number of such un-ordered trees is given by the formula mentioned above.

The points that effect the count are
1) The permutations of this set of companies and
2) Whether the A merging with B - must be treated same as B merging with A (commutativity). To view it differently, if A is a merger of K companies, and B is a merger of m companies, should we take into consideration the chronology of the events, because of which A->B is different from B->A.

Taking point 1, we have N! permutations of N companies.
Now consider point 2. Because of the properties of full binary tree, there are N-1 internal nodes with a tree with N leaves. Commutativity can be simply viewed as a mirror rotation of the tree (subtree) at an internal node. For example.

O O
/ \ == Mirror Rotation on O == / \
A B B A

Since there are 2 degrees of freedom the number of such combinations possible for N-1 internal nodes is 2^(N-1) . This is easily seen if you view the two possible postions at an internal node as 0 and 1, and then count the number of N-1 length binary strings.

With this prologue, lets look at the two problems of company mergers:
1) Where the timing does matter: In this case only the first point (about permutations) need to be considered and so - the answer turns out to be :
T(N) = C(N-1) = N!/N * (2N-2 C N-1) , where (n C k) is n choose k - or the kth binomial co-efficient.

2) Where timing doesn't matter -- i.e. A->B is considered same as B->A, we need to nullify the effect of the mirror trees, because of which a division by 2^(N-1) is required. SO the formula turns out to be:
T(N) = C(N-1) = 1/2^(N-1) * N!/N * (2N-2 C N-1) , where (n C k) is n choose k - or the kth binomial co-efficient.
OR

T(N) = C(N-1) = (N-1)!/2^(N-1) * (2N-2 C N-1) , where (n C k) is n choose k - or the kth binomial co-efficient.

There is a simple proof that the number is second formula is nothing but (2N-3) !! (double factorial).

Labels: , ,

Friday, August 24, 2007

classical guitar

This is the first time I have seen classical guitar in its full glory. Apart from the fact that it has nylon strings and that the fret board is much wider (good luck ! fingers !!) I had no clue, that it can be played so beautifully. One of my music enthusiast friends pointed me to this video and I have lost my mind over it. You can see it here.


This song called "Bohemian Raphsody" is from a 70's band called Queens.

Sunday, August 19, 2007

come back

It was this afternoon, a bright sunday Bangalore afternoon, while I was chewing on some old novel, ... no wait .. take back that line .... it wasn't supposed to start like that. Just to erase any false impressions, I don't generally chew on old novels in the afternoons, you know, like sitting in the porch or balcony, sipping coffee etc. No, that'll be a completely wrong picture of me. It was just that I was totally bored from gawking at my lappy, trying to figure out a bug in my project, which is a darn wrong thing to do on a Sunday, btw. But, what can i say ? All the 4 movie channels, two music channels, two science channels and two cartoon channels, were airing nothing of the stay-glued-to-the-chair types. And that bug I was talking about, has been infesting my grey cells for sometime now.

Anyways, where was I ? yeah ... as I was pouring over one of my fav. literary marvels, I realised with a brief start that it's been exactly four months since I wrote anything here. And I judged it's only fair to give the future historians some clue regarding this gap and save them from some agonizing nights. To relate it in the style of Chris Gardner (Will Smith) from the movie "Pursuit of HappYness" - this part of my life, right here ? is called - "getting married". Yup. That's right. Everyone does it. I did it. You may look askance and enquire if I had no other good reason than that. But please, I got fed up of explaining myself to people, arguing with them and all that. I'm over that now. Not that life's been unpleasant or negative in anyway after I got married, no, I don't mean that at all. But I have relatively radical views on marriage. Yes, both of us and our families are happy. Ask the CIA or anyone.

Here's a link to a video generated by one of my close friends, capturing some glimpses of the historical event. So many of my college buddies are getting married in the recent past and going to tie the knots in recent future, it's like participating in a grand gala marriage fest. For me, out of marriage, I got a lot of things. For starters, I got a lovely wife. Okay that's kinda given. I also got to meet my brother, my sis-in-law and my nephew after 3 years (bro works in US). Got to meet lot of relatives, whose names I'd forget if I didn't meet them for a year or so more. Got an excellent electric guitar from my friends (watch that you tube clip). Definitely not the least, got my parents to stay with me here at Bangalore. What more can an orthodox-family-born-music-junkie-Bangalore-lover ask for ?

This guitar, it is just amaaaaayyzzzzing. I'm impressed by the kinda faith my friends are showing in me by gifting me an original Yamaha electric guitar (speaker being part of the package). All this considering I'm an amateur strum guitarist who plays the chords from "Hotel California" for the 20th time and looks around like he's composed the song himself. Just so my parents and my neighbours don't get hard of hearing, I got a universal-jack-to-speaker-jack converter plug and now, only I get to listen to all the cacophony that I generate. I was trying some relatively easy carnatic pieces on it and really got excited by the quality of sound. Expect me to post my musical experiments here. And so, beware. ;-)

Friday, April 20, 2007

The Remains of The Day

"You ... most most ... jewel saar, life ... pakka jewel", said the auto guy, squeezing my hands and saluting when he was not squeezing. His face was assuming expressions varying from surprised happiness to appreciation. I was impressed, thinking that he was doing a good job of whatever he was trying to do and my ego satisfied (of course, assuming what he meant to say is - "You are the crown jewel of human race" or something to that effect ;-) ). Now, when I look back at the incident, I felt I just did the right thing at the right time, that is all.

Last night, it rained heavily. It started around 7:30 and was non-stop till about 11:30 types. The 8 pm cab which came at 8:30 to the office, gave us a thorough tour through the most muddy regions in Bangalore, and safely got us into the downpour at Sadashivnagar at around 10:30 pm. It didn't make sense to stand and get drenched, when i can rather walk and get drenched. So I started walking placidly, sandwiched between the shower from top and the 1-foot-high slushy water on the roads. After a while, I found an auto guy eyeing me with all the challenge he could muster into his eyes. I gave in and asked him if he can come to MES College (a landmark near where I stay). He replied a defiant yes, adding that it would be 50 Rs. Of course, this was plain robbery, knowing that it won't cross the minimum of 12 Rs from where he was positioned. I gave in to this too and smiled at him knowingly, at least to let him know that he wasn't just walking all over me. Things were going fine until about 40 sec after the auto started when it came to a halt and just didn't move. This guy tried whatever he has at his disposal, like swearing, pulling the gear violently, opening and closing the engine box etc.

As this was happening, I somehow felt pity for this man for whom that 50 Rs must be god sent, and how he was really excited about the prospect of loosing it. His efforts went on for a few minutes without response from the auto. I then asked him to just go back a few yards to a petrol bunk, where he can get his auto repaired, I'll pay him a 10 for the ride till then, and go walking from that place. I could clearly see that he was moved but not satisfied. He asked me to sit inside and pushed the auto back to where I had indicated earlier. But, as he came there he noticed that there was an parellel road running which was slopping down. He immediately said that the problem is solved and sat in the auto and let go, after a while the engine picked up and we were just fine.

As is my habit, as we reached and as I handed over the money, I asked him if he knew the route to where he needs to go then. At this point, without any warning he was holding my hands and praising me left-right-center. It was sort of unavoidable as he was holding the money and my hands together. It was 11 pm and and I was feeling extremely tired because of the heavily bumpy ride of 2 hrs in the office cab , the drenching in the rain and the blood donation from afternoon. I pacified this soul and got into the house.

My part in the whole incident, I feel now, was partially inspired from reading a book that one of my colleagues gave - "The Remains of The Day". It was a booker prize winning novel from a Japanese writer Kazuo Ishiguro. I was surprised at how a Japanese guy wrote in detail about the British psyche during the post world war times. The story is told by a perfect English butler who serves under an influential Lord for around 30 years.

This butler, during his holiday trip through rural England, recollects many of the reminiscences of those times during his service with his previous master and reassures himself that his life hasn't been a waste serving his master, whatever gossipers have to say about him. At many places during the narrative, there are good discussions on what is dignity, what is greatness etc. Though these were from a English butler's perspective, and how things changed over generations, the general message was not lost on me. What drives us most to do whatever we do, is a sense of accomplishment, that is , the task itself. Most of the time, if we were to be asked during the work that we were sure about the result, the answer would have to be no. But there is always hope and there always will be. It somehow feels nice to do the best thing possible given a situation. I can't explain but I'm sure many of you will feel the same way. You many not always be master of what you face, but you'll still be master of what you do when you face whatever you face.

For example, last night's situation. I was drenched. I can be more drenched and keep walking and catch cold or something. Or I can take the auto and leave. When the auto stopped, I could yell at the guy and stamp out bad tempered or I could have tried to help both of us out of the situation. This list goes on and on. It's like a binary decision tree. I do the best possible at a given situation or I won't. Really inspiring novel, it leaves you with a feeling of purpose in life.

I would recommend this novel for anyone who has a little inclination towards Victorian type novels.

Tuesday, March 20, 2007

my visual DNA

Saw my friend PV get his visual DNA and checked out mine.

Monday, March 12, 2007

babies will be babies

I always get strongly reminded of assembly language mnemonics when i hear babies speak or being spoken to. For instance,a "AAA UMM" (meaning LOAD ACC) or a "SSS" (need I explain ?) or even sometimes a "DADA" (usually short for the warning "Do As told, Do As told") takes me back to that course that we struggled through during our grads. But, we are steering clear of the original purpose of this post. Ahoy !! full astern, me matey !!

I was travelling again this weekend, after meeting my parents, in a train which seemed to be preloaded with kids and babies all over. I particularly speak about a 1 year old toddler (you may ask me how do you know it's one year. One knows Dr Watson, mail me for explanation ..) who was in the same compartment as I was. My original plan as I entered the train was to sleep off early so that I could get up early and finish my novel in the solemn hours of the morning. It was a spine chilling Victorian murder mystery, where everyone including the narrator move suspiciously with conspirational looks, at night, with candles across alleys and black cats strewn all over. Such a thing mustn't be pursued at night, that too in train when travelling middle berth. Anyway, so here I was, trying to get some nap. Starting at about 11:30 into the night, a series of disturbing events proceeded to occur, as Agatha Christie would have put it.

"gaarrrrrrrrrrphhhhhh", an upstairs neighbor opined in his sleep.
This somehow didn't agree well with the toddler downstairs, so "aaawwaaaaa !!", he replied back.
I was very shrewd in imagining that things were getting hotter and tension was spreading in the already stuffy compartment air. Any moment now, the bubble may break.
The snorer didn't change his opinion even after the new development. "grrrrsnnnzzzz", he declared this time. The toddler didn't back down, he raised the bet by 10 dB more and returned the call in no mean terms with a scintillating "AWAAAAAA!!". After that the little champ was unstoppable. Good that the snorer was no way reachable to the baldie, for I had no doubt that he was looking daggers at the snoring offender. This, of course awakened the upstairs neighbour to the facts of life and he turned away subdued and humbled. In the meanwhile, the mother, father and other relations of the baby got up and started to calm him down. Very peculiarly, this chap needed no calming down, if the lights were on. So, as soon as the lights were on, he began to lie down beside his mom, seemingly deeply satisfied.

If you think that the unhappy episode ended here, you are completely mistaken. Young spirits, once set on fire, are difficult to extinguish. I was tussling on my berth for sometime now and realised that the reason for the fidgeting was that the light was still on. Immediately I realised the gravity of the situation. They say men must go through difficult times to learn. Here, I thought, was an opportunity. Not that I wasn't careful. I gave a few sidelong glances at the little chap for about 10 minutes. I feigned sneezing for a bit, just to make sure he was really asleep. After passing these tests, I made the mistake of switching the light off. This move truly aroused the fellow's sensitive feelings and he resumed his incantations at a level which the tennis players generally use while tackling a particularly difficult serve. He would have made Monica Seles feel like a puny ant. After I put back the light on, I murmured a few apologies to the parents and got back to my tussling. Only at around 3:00 am did the fellow slept soundly without taking offences at these silly things.

The night's incidents interested me immensely and I took up watching this warrior even by the day. I looked past the edge of my murder mystery every now and then. And the wealth of information I gathered by this act was very profound in nature. Here are some baby facts:
1) If you give a anything soft to be eaten to a baby, his algorithm to achieve this feat is simple. He first squashes the object on the floor with both hands, spreads it well and takes of pulp of the floor to keep in his mouth. Pretty savage, I know, but there it is.
2) Any object that is not squashable is to be put directly into the mouth for a preliminary examination.
3) Inviting the baby to you with a brief "CHUCHU" is quite comparable to a unassuming first year, crying out loud to be ragged in a senior corridor full of people.
4) Never remove the safely clothing tied around the waists of these fellows. Babies are quick to take offense and their general method to tackle the situation when this happens is to let go.

I got down the train, very wise and chanted the title to myself.