Skip to main content

Rain, Bombay, and card games.

Finally Bombay gets to see some lovely rain. This isn't a good news for most, as the rain is causing floods all over the place. But one cannot stop feeling awesome (with a feeling of guilt) looking at the sea while it rains so heavily here. Marine drive looks just perfect when it rains and the skies are grey and the leaves lush green.

For people who love Bombay here is a simple quiz question:
If you were to take a friend of yours to the best place in Bombay, which would it be?

My answer is the most typical one, Marine drive. (Also watch Wake up Sid to know why I use the word "typical" to describe my choice. More about Wake up Sid later.)

Also here is a simple and cute problem I came across.
Let s be a sequence of numbers from {1,2,...,n}. Let the Longest Increasing Subsequence (LIS) be a set of numbers from the given sequence s, such that when its elements are arranged in the order in which they appear in s, they are increasing and there is no other subset of numbers (strictly) larger than this with the same properties.

For example: s = 1 3 7 2 5 4 6.
The following subset {1, 2, 4, 6} when arranged as they appear in s, give 1246 and is the LIS.

Problem: Given a sequence over {1,2,...,n} find LIS.

(I could have written this in fewer lines if I could use math symbols. !! argh!).


**********

On a completely unrelated note let us also look at a card game:

Patience Sorting:

You are given a deck of n cards which are numbered by numbers in {1,2,...,n}. You get one card at a time from the deck of cards. The first card is put in the first pile. Any card is put in one of the existing pile, if the topmost (the most recently added) card in that pile is larger than this card. If no such pile exists, then another pile is started.

The goal is to minimize the number of piles.

The greedy algorithm places a card in the first pile where the most recently added element exceeds the current drawn card.


*********

Here is why we suddenly started playing cards, instead of finding the LIS.

Claim: The number of piles created by the greedy algorithm (#p) = the length of LIS, l .

Proof: #p > = l: the elements of the LIS will be in distinct piles (due to the greedy algorithm).

#p < = l: Suppose not. There exists a pile P that does not contain any element of the LIS. Let t1,t2,...,tk be the top elements of piles which were created before P. They are all smaller than the elements added in P. Also all the elements added to piles which were created after creation of P are larger than the last element added to P. Hence, one can create a longer increasing subsequence using P than the LIS. Thus a contradiction. It is easy to construct the LIS from these piles, right?

Popular posts from this blog

The "What next...?" demon

What next?.... When I was a kid, I always thought that there is a certain age till when this question will bother me and after that, like for my parents, things will be in order. Life will fall into a routine and I will never again be confronted with this demon called "what next?". But turns out, for our generation, there is no point of rest. The demon is a part of our life like stability was for the generation before us. This realisation is also stale by now. In fact, it has been more than a few years since I even resigned to this way of life. The time period between such a realisation and resignation was hard, I must confess. But not anymore! The confrontations with this demon are a reassurance of life itself! (feels embarrassed after having said such things....) My childish philosophies may be sounding hilarious to you (reader). (Thank me for the entertainment! You are welcome!) What I wish to announce is: for a while, I do have an answer to one such "what next...?...

Slumdog Millionaire, what's the fuss all about?

I saw the movie a few days ago. I really don't understand: why so much fuss? If an Indian director makes a fully filmy hindi movie, no one gives a damn about it. But some non-indian comes and makes this movie and people are going all ga ga about it. A.R. Rehman has given music better than "jai ho". Anil Kapur has done roles better than this. This movie has set new records in making a big deal out of a not-so-amazing movie. I say this because, even a huge fuss has been made about why there is so much fuss about this movie. That is like the second order fuss about the movie! And here, I am making the third order fuss with a huge lot accompanying me in doing so. To start the tirade-- The main guy is such a put off! He has a unique expression on his face, indicating he really has no clue what people are talking about. You are supposed to be poor, not dumb for god's sake! Even some of the witty lines are lost due to his dialog delivery. For example, when one police man say...

Valentine's special

its a love story of two strange people who never knew they could fall for each other when they first met they only ended up fighting but slowy it became clear to them that they sure shared something a small problem happened when pride overtook him he thought she was less smarter than him she would solve a puzzle and he would solve it again he would tell her that she was simply an idea away from him... he said that he always gets this idea and then he does all that she can and probably much more... one day she decided his behaviour had to be checked she thought for a while and then she said... fine, then you sure can do everything but if you are strictly more smart you have to do the following think of some puzzle that you can easily do and then give it to me to solve and lets see if i can't do.... all the king's men and all the king's horses could not come up with a puzzle like this the duo got closer and the world around more curious today as it stands the puzzle is still ...