Jul 14, 2009

The ghost of Red Black Tree.

My problem is simple.

I dont know when to do an operation called rotation in a Red black tree. Nearly every other programmer on earth knows it and nearly every one can lookup on internet and find out. 
ok now. After about leaving it for 3 or 4 days I find this problem intersting.

lemme look at the problem once again:
i have a tree like this:

3 black.

now add 1 more. i add red.

3B
2R nilB

add one more.
3B
2R nilB
1B
nilB nilB

I get a violation of Red Black Tree. The Red Black Tree Ghost is not happy. Apperantly its customes are violated. 
3B is farther from black than it should be. F*** I hate it.
But one good thing I came to know.
As soon as you get that you are adding a child to a red tree. Whoa man you are violating the ghost spirit of Red Black tree.
Now you got to follow a custom rotate.
question is how to rotate.
I got a clue:
wait I look at it again.
 now my doubt is: which one to rotate? or rotate around what?
well to start with:
I know that if the final position is 

2B
1R 3R

or 
2B
1B 3B
The ghost of Red Black Tree remains silent.

Ok now back to rotating bussiness.
Tree, pardon me Red Black Tree was like this

3B
2R nilB
1B
nilB nilB

I do a right roation.
Non leaf is 2R.
swap 2R and 3B (with color or without color?? go to hell I choose without color.):

becomes like:
2B
3R nilB
1B
nilB nilB

oye its wrong.
it should be
from
3B
2R nilB
1B
nilB nilB

picture rotation
pin at 2R and push 3B down.
now it is like:
2R
1B 3B
CooL.

once more.
now tree.
2R
1B 3B

oops i need big numbers
adding 0s.

20R
10B 30B
add 11. Add Red keep peace.

20R
10B 30B
         11R
add 9. Add Red Keep peace.
20R
  10B     30B
   9R         11R

hey I am seeing my peace is just for 2 steps. any ways I will keep atleast for two steps:
Add 29 and 31. Once again add Red Keep peace.
20R
  10B     30B
   9R         11R      29R    31R

Now I must add Black.
Add 32 B.
20R
  10B     30B
   9R         11R      29R    31R
   32B
Violation (:X:@)
Rotate around 31R. (Y? ~@:X)  (i got to sleep also, uh)
Ok Left Rotate. Y? hmmmm... because violation is at the right child, yeah i got a rule :).

now i have to type all that also... my roomie came. i gotta sleep.
20R
  10B        31B
   9R         11R      30B    32B
  29R   

Not at all helping Rotate once more.
20R
  10B        31B
   9R         11R      30B    32B
  29R   

31B
20R 32B
10B     30B     nil nil
   9R 11R  29R nil

actually it is balanced.
now you go back to paper and disturb your peace.
I got to sleep. I will get up early in the morning and continue.

Jul 5, 2008

splash in the eyes

been to a temple with two of those today.
"hey, what did ya ppl pray?"
yeah good question, I really wanted to know after all.
"Nothing I simply pray, nothing specific"
you pray simply like God give me peace?
"yeah I did so"
ok
then what did you pray?
"I thanked God for all the peace I have"
what?
Splash in the eyes. when they were most tightly closed.
when it was hardest to open them.

Sep 11, 2007

Do Disturb -Man asleep

It just takes open eyes and you can see how blind you are...
Really no excuses....
The virtue of meanness.... I loved it... certainly that makes life easier.... but alas not so happier always...

The virtue of meanness... such a beautiful world with you at the center... everything fits so perfectly, everything so meaningful and if something does not fit? something is not perfect? No problem you are always mean enough to make that a fit, and lo! you are happy again... even that's not all! just make things fit for yourself and after that their is always plenty of time and you can really think for others also, after all you should care for others and yeah you found yourself caring for others, such a beautiful soul you are...

Alas! That didn't last longer than that! Some how by myself or forced by others I had to open my eyes... how wide I opened I don't know, I want to know... but at least a flash of light came piercing... such an uneasy light to disturb the lovely soul sleep... but wait light can not be as bad... that makes world warm and lively... yeah that really does all that... but what? I am still sleepy! Peaceful, dreamy sleep, all one can ever need... I don't want to wake up, I want to sleep a bit more... such a dilemma. Give me just a little bit of more time I'll wake up soon...

Dangerously familiar words... I must be getting late to somewhere... someone wants me awake...
what is it? who is it?

Jun 21, 2007

about me

Optimist at heart, pessimist in action. So has to spend a good time with my self to generate a good amount of optimism. I think slow and I hate excitement, the reason being it costs me my sleep. I love mornings of every where and the best thing I like is lying on my bed and thinking of every thing. So this combination often leaves me sleep deprived like a workaholic. I used to have my share of fun by remaining silent often in conversations while now I know that it is equal fun taking part in them and thought productive too but surely less cozy, so whenever I speak it is a truth that I choose to speak. While I have to choose to speak it is not the truth otherwise. Because I speak less some people think I am sane then I admit I have learned to laugh at those people's stupidity rather than mine. My less active mouth is direct consequence of lesser active brain which is in turn the consequence of less caring heart -the reverse sequence is also true. But I am sane nonetheless.

I love to read not because reading is thought provoking but because it is thought quenching exercise for me. Streams of words are like a train which a child has seen first time and also just keeps watching it amazed by the motion and thinking nothing, so I am never a good reader. Nonetheless writing is thought provoking and I like to pen down my thoughts.

I like nature with just a touch of human intervention. The human intervention in nature has two products. It tailor makes nature for a good comfort and it spoils the beauty of nature simultaneously. So a slightest touch of human brain for physically bare minimum active person makes nature just heaven.

I like physical hard work and that I like that about me. I like it so much that when I do hard physical work I often hibernate my brain to reanimate it when I go to rest and the brain responds with full vigor eating my precious sleeping time.

I like to see the qualities in people. So far I have touched and felt bravery, meanness, politeness and hard work, I love brave and slightly mean people while I respect others enormously....
(to be continued)

May 3, 2007

How did ya helped changing the world map?

The map of the new world: (http://xkcd.com/)


Your new resume should contain following answers:

  • What are the places you live in?
  • How many people know you at the places you live?
  • Which food you like most?Visual moving, visually still or non-visual (text)?
  • How did ya helped changing the world map?
  • Or have you ever created a new place in the new world?
  • Have you been ever kicked out of some place?
  • Do you ever heard of hanging out in old world?
  • What would you do if there is no laptop of yours?
  • What will you do if your company bans you for going one all of your favourite living place?
and So on...

May 1, 2007

True and Customized Howler

Send Howler* to a friend when he/she does not reply your help call at a night out because he/she is sleeping:
A friend in need if is useless, unhelpful, betraying, lazy and sleepy, when you want most of your time, dreamy to the point that on the brink of losing touch of reality, living in fairy tales when you need answer about something at a night out, deliberately unlistening , illiterate after reading SOS, knowingly ignorant, blank, reaction less, careless, looking puzzled when you need to solve the problem most, replying late after time has gone, sending excuses in the morning, wasting candle in day light to run out of it in the night is certainly not a friend indeed...

*What is a Howler? Click here

PS: In my case it is supposed to be funny for the recipient, though you are free to let the other interpret whatever you want.

Apr 27, 2007

The rope called hope

some times the need for hours is the most exciting thing of your life become a routine to give room for more such things.. this way goes for betterment, of you and hence life I guess. Just tie your self to hope or positive attitude the other comes readily but may not come early and of course nothing is easy as if they are ends of same rope tied to success or more importantly happiness. Be happy if not then be hopeful.
All in all be young. Well I am literally. Just want to go back in time while moving ahead. Just watched Bluff master. there are really a handful of days worth remembering. Lets make this day one. Be young.

Apr 26, 2007

lessons of life

No matter how hard I try to avoid writing this "I grew up post", I only come back to this. Life is just a practical classroom for me now. It just keep telling something and something incessantly, I don't know why? Yes I grew up... or if I am no grown up then at least I am no longer a kid. A few days ago I realised being grown up is not so fun after all... I few more days ago and for months I thought it was great fun, just understanding things and see how bunch of stupid little ones don't understand those. Live in a sense of greatness... wouldn't that be fun? That would be. But just then life told me cost of that everything... where is the innocence? after all understanding everything is no more important if the other claims not to understand. The other says I don't care if you understand or not... I just know how to be happy...
It hurts then.... but then I don't think growing up is that bad after all, in in congruent company every good thing can become close to a waste... you can't be a great acrobat in the village of blinds, you have to good to ears then... that's life and that's one more from the book "lesson of life"....
Oh I just realize may be its true after lessons there always come tests? so any body with previous test papers? I better start surfing for that online :P...
as of now time for life to go on...
good bye.

Apr 10, 2007

The best of college: Title? Can any one really afford to give one?

Just because I am a blogger and just because I am doing my last sem of 4 year engineering course I feel obliged to write something about my college days, "You know how well I loved it " types.

Well yes... I learned a lot in the college I came here as a kid and turned into .... blah blah. Yes that stuff is all applicable to me. But I would only like to talk about the best of the college... what makes it the college...
Have a look on my blog posts... well I write in it with the best of my efforts and using the most beautiful of the language (to the limit of my skills, ofcourse) in other words "straight from heart". And then one of my friends just came to know of my blog... well other reasons of coming to my blog may exist but the most applicable is the presence of G-Talk gadget in my blog which works well in computer lab....
And what does he do? He reads some of my posts and uses comment facility to do the most important thing we learned in the college 'the bak' ( word definition: time pass chats)... yes people what is the most interesting thing is we start any where any time using any mode of communication.... he commented first as some anonymous then when he knew I am online and replying ... what's the next big statement : " yaar..badi thand hai [A.C. in the lab] yaaar...kuch kar..." not to mention the names he uses, God it supposed to be a sincere blog.

https://www2.blogger.com/comment.g?blogID=35301718&postID=4380298655866036942

Yes my beloved readers... people climbed mountains in the college's adventurous environments but what I like the most is the camp fire of chatter that only needs two people on any mode of communication....
Let the time and space bend.... they are never bent enough....

Apr 7, 2007

God's Will

I was talking to a friend of mine today...
I just asked my friend "why you think I am a good friend of yours?" Well yes... it's always good to listen to your virtues to lift a bit of confidence of yours. ( Good trick, it works ;) )
The friend said "first of all you are a person of clear heart and..."
whoa!!! internet disconnected on the other side....

God's will, may be? But what it is?

Well may be God doesn't want to let me know y m good in my friend's view point...
or may be every good work has difficulties in the start, so I should ask the same question next time also....

or may be its enough for me to know that I am a clear hearted person... well that reminds me a very good thing one other of my friends tells me ... "we'll be happy yaar... because we are good people"...

well to go further or not with this topic... we'll decide at God's free will on next time....
as of now ( wen i m writing) may God writes a good night in my fate...
and as of now( wen u r reading) may God give you a nice time....

On God's will ( as the computer center closes down) I sign off...

Apr 3, 2007

World is flat no it's really an e-chaupal

These days I am reading book the world is flat by Thomas L. Friedman .
The book is about how technology and more and more people adapting to technology changed the world. Mainly the world of business and in tern our very lives. He gave many example of impact of technology in daily life and competitive business. The interesting thing about reading is when you read something your mind goes in that direction automatically. You are like in tuned with the author and considering my self equals Mr. Friedman I just found another example while reading a thread on pagalguy.com. The thread was about people posting to buy laptop, discussing configuration of a suitable lappys and whew local people coming together to buy laptops in lot to buy them cheaper. So it's like consumers using the technology to find the best deal for them and the most important part is that the site was created for people coming together for discussing their MBA entrance preparation and they started making groups not only online but in locals also, discussed all about their study, plans and now are now buying stuff together.... It's like it is becoming a village chaupal... really and e-chaupal.

Mar 30, 2007

Straight from heart, without being high :)

The Risk which is what I miss.
I don't know whether I am right or wrong. I just feel I am following the correct course, but I certainly know I am missing much. Take drinking.... I grew up listening it is a bad thing to fall upon... which it is... than when my friends drink and I do not I am missing the fun and the social circle. The pressure of being socially accepted increases and by doing just what you ought to do I certainly miss the opportunity to hone my ability to handle the situations when something is wrong. I loose confidence and that is the worst part. So that means to follow the right track you must have to be brave to retain your self confidence because once you lost it. You are a coward who is afraid of trying adventures rather a person who thinks enough to go to the right side. This situation is possible as I have seen it in some of my colleagues, but to what extent I don't know.
Whatever. The only recourse for me is to become braver. Do the right thing and simultaneously love people that makes you polite and adjusting. You must know what is wrong who is wrong and you must know how to love everyone.

Now talking about what I miss when I don't drink?
Social circle.
Being cool.
You have to defend yourself every now and then and stay confident .The fear of being out of circle and consequentially leading the lack of self confidence. So confidence I miss.
The experience -Yes I haven't even tried [as they call it] once. After all what is wrong in trying once.
Certainly the fun and adventure in being High spirited.

And what I gain:
Health : I don't know what am I going to do by preserving my health, I am kinda fitness freak and still I am not so fit.
The money, yes sure.
The culture of my family. No one drinks in my family (call it the Khandan to make sence) and I love this part of my family most. The look cleaner. But then I dont know in what amount I am saving my culture. My lil cousing nyways gonna change the culture.

Ok what I think about loses and gains?

Social circle -ok not drinking would push me back a little but still I am ready to work out participate more in othre parts of social circle, say more of personal touch to ppl.

Being cool - they say don't try to be cool after all what is it to be cool? 'I don't care ' isn't it?

You have to defend yourself every now and then and stay confident -the fear of being out of circle and consequentially leading the lack of self confidence. So confidence I miss.
- I grew up defending my self from such accusations. I think it's the easier thing for me now. Regarding self confidence. I am on upward trajectory see the publishing this post is proof of this phenomenon.
The experience -Yes I haven't even tried [as they call it] once. After all what is wrong in trying once.
- I miss it. No comments
Certainly the fun and adventure in being High spirited.
- same as above. But I am not the one who cares much for fun.

Feb 20, 2007

HOLIDAY

The most difficult to plan in the world is a single day holiday which is hard earned and which comes after sacrificing the whole world's interesting aspects for a considerable amount of time [in my case 2 days' time is considerable enough] The expectations attached with this kind of holiday easily equal expectations attached to Sachin Tendulkar's batting, if not greater, but then my holiday is no Sachin Tendulkar and this little time slice always squeezes under pressure. Probably my one day holiday can emulate Virendra Sehwag... Yes! I decide it can. So I give it more and more chances on the basis of mighty past performances... after all the last sem of college life is no less then a world cup to win....

Feb 19, 2007

Life as I see it: Life as I Love it

'Howz life?'
On the refreshing pages on the webs of the wild world, I see the phrase and I make my contributions by writing it repeatedly... again and again! The phrase gets stale in my mind, I become bored... but then I start loving the content of the phrase, the life!... I just fell in love with its pace, when I actually live the relatively slower part of my life... at least slower than what I lived in last 5 years... the variety...I love the happier and lighter moments, and, the part in which life grills me amazes me, of course afterwards. I wonder on the interconnections and overlaps, I like the test in which life puts me when both kinds of moments come simultaneously... I just begin to love the stories of other human lives... and I find myself lucky when I see some good story tellers and good story creators on my side, telling and creating the stories of lives, repeatedly and continuously. I just see the contents of lives repeating every where, every time in new combinations... and my awestruck heart thinks of the designer of these combinations! When I am helpless, out of patience the story tellers refresh me, blew fresh air of life in me. When I try to relearn how not to not do what you want to do and the story creators step in and such lively stories makes me younger and invigorated again.
There is too much to tell and write about a small single 'I', I wonder how interesting this big ocean of lives would be. I am happily surprised, perplexed and often confused, I just move and ask.... hey! how's life? and it goes on.

Age of Love...
Well they say love sees no age... as of now I don't know about that because I havent seen the ages... but I can certainly say age sees love.... or atleast pretend to see. Never before I fell in love so many times [:)]... the frequency of being in love surges... never before I felt how is it to be in love on daily basis [;)]... and alas with all this I have to come to know that the love which changes its face with days of week, is also exists in space and time, and faithfully and mercylessly follows the rules of the same, for its gravitational effect decreases directly as a fucntion of space and time.... but never becomes zero!!!

Jan 28, 2007

Now It's all bussiness... what a bussiness (man ) is?

About the post: The post is about the prevailing corporate scenario of India in these days. The quality of a business man and some here and there stuff about business...

What caused this post: Just a few minutes back, I had recent issue of Business Today in my hands, I read two stories in it.
1. The class and growth of small FMCG players in Indian market. Here small is not actually small. They have turn over of 300 -500 crore INR and profits of 50-100 cr INR. They are small considering the larger players like Hindustan Lever Ltd. 12000 crores and some others like HLL. These small players are earning good profits and all of them are furiously working to expand themselves in domestic and global markets. Many of them already have presence in global markets, and revenues are increasing. Their main strength is that they are very close to market and understand them well, and are invotive in there approaches and marketing and many a times products.

2.The upsurging and renovating Bihar! After change in government in Bihar around one year ago, there are real changes in Bihar itself. Law and order is improving, infrastructure is being built ( Bihar government plans to spend 3000 cr in roads) they want to spend in education, government is wooing investors with cuts in taxes be it road tax, entertainment tax if you invest in it with more than 1 cr of your money or exemption from electricity duties for a substantial period (that is 7 years for new establishing industries), they are looking forward at tourism, hotel rooms are being built, and private players are being encouraged for building these hotels, they are making golf courses for tourists. Bihar govt. has identified seven sectors in which they can promote tourism that includes Buddhism. Bihar government is looking at tourism as a major source of revenue. For all this they will need power and they produce only 10% of their needs, and they are trying to make their own power too. Government is working in that direction also.

Now what is common in these two articles is the persons who are causing all these stirs. The CEOs of these companies work restlessly, that is around 15-16 hours a day, 6 days a week, every one more or less the same. The chief minister of Bihar is also of the same class he works in the same spree. This is something to me. If you are good business man what you have to do is you have to work day and night with full of your will and might. It is this aspect of business which I am attracted to and what I want to be. One more thing that surprises me is that why in the earth one wants to expand ones business. Well the reasons are obvious but still I just don't understand where these people find motivation, is it the burning desire to be greater than all others or desire to play the best of your might and ability, I don't know. Well whether I will be a good business man or not is a matter of time, but as of now these people are role models for me. Hats off to them.

Nov 29, 2006

Maturity or dying enthusiasm....

At the juncture of my life I start to understand how the time component acts on a human brain and how the term life can be used in a little meaningful way and not just in place of a 'wazzup' I just understand what a risk is and I begin to understand what is 'experience of life'. But as I understand the meaning of the term I am just perplexed what is better more importantly what is appropriate? I just fear will experience take my risk taking guts out? well every body wants to be a James Bond!!! or I fear what if I become fooled by just not taking use of my experience.

The things caused me learn all this? well they say people learn from failures and I say I will learn too but right now I am perplexed what to learn? I clearing IIT JEE, prepared for CAT though wasnt much hopes from the start but when you start giving time you expect a bit... and with some advancement you see, you expect expectation as relly expectable and I think you should expect that. But after being shattered in CAT-06 too I think again I just experience that I am not for the top notch, I.... only well that is the part where experince advocates to be the winner...

But than the willing to take risk and come what may I'll do it any how youth comes and say, keep trying and one day you will succeed, may be the day not soom but keep just keep your standerds high, just dont forget such failure are integral part of success just be hopeful, just take this chance, just take cause you ought to be optimistic, just take it.

Well then shall I not use hard earned experience, isnt it foolishness, or should I lie to myself "yes, I can do it", but then would I succumb to the situation and take the path which has atleast the security... well honestly my heart wants to be the youth one but the other one is too luring... don't know what to do? still lots of time for me as of now... I decide to keep procrastinating, just like the court of law judges precisely the next date of meeting... just like I do.

Nov 25, 2006

The Comment less comments.... when no serendipity exists....

As I write almost anonymously ( No one I know of knows about this blog)... the desire of a serendipity creeps in to me... I need a comment on my comments... very unlikely int see of blogs... so it proves I like lonliless but only till I am not alone...
Any ways the last night I watched Dhoom II and I wanna say I wanna be an Indian... and no one is Indian among my colleagues.. we all are transformed.... in to the westerners... the british software is still working.. don no what just cant write too much... just as impatient, just as scared as always to add another thread of my thoughts.... it will end for sure... as of now... I end my post... goodbye - first to the first of my reader(s)- and thanks to first of comment maker....

In hope of surrendipitous supremity....

Nov 23, 2006

In the mood of get going....

In a little lighter mood I go on watching sleepy me.... I watched Kanchanjangha ( S.Ray) Today... frankly that doesnt apply to me... I search for what I like and the search is going on.... untill I find something... as of now exam time so got to study.... actully I am here to keep my self away from sleep... I am having a lot of it... and I like writing cause it tell me about myself... so I think this time I'll stay here... I hope this blog to be more useful for everyone in the time to come....till the next post good bye....