Discover the power of algorithms

Complexities of algorithm, thier applicability. Optimization techniques associated with diffrent algos.

Discover Power of Blogging

What is Blogging , is it a Dream or Passion or Award or Making Money ?

Think Diffrent, be creative

Let's see how much conclusion one can draw from it. This will help testing your creativity.

Discover the power of technology

Technolgy, Programming, Optimization , Gadgets and more...

Discover the power of Blogging

Google widgets and gadgets.

Feb 28, 2010

How to add label cloud to your Blog ?

Its very easy to add label cloud to your blog.
Just follow below step to make your blog tag cloud enabled.

1) Go to Layout section of your blog.
2) Add gadget named as "label"




3) Configure labels as shown in above figure to Display type "cloud".

This would help your blog look more organized and easy for navigation too.

Keep Blogging
-Tajendra



Feb 27, 2010

Understanding which is faster Post or Pre increment operator ( i++ vs ++i ) ?

In c++ pre and post operator are used with variables where one need to just increment or decrement value by 1.For incrementing value ++ operator can be used and for decrementing -- operator can be used.
Its use is very simple one can easily say ++i or i++, to increment its value by 1. Many a times i found people very confused about it's usage (at beginners level) and some professional showing lots of concerns about its performance .That's what made me writing this post.
lets focus on its use first:-
One can now ask question that why there are two different version present for if we simply need to increment or decrement the value.
Lets take one example to see its effect in expression for post and pre increment operator :-

a) x = ++y; //pre increment
b) x = y++;//post increment

For above two expression value of x will be different. In expression (a) value of y would be incremented first then it would be assigned to x. And in expression (b), x would be assigned value of y first and then y would be increment. So if the value y is 5, then value of x would be 6 in expression (a) and its value would be 5 in expression (b).




We are now aware of its usage and impact in an expression, now lets find out which is better ?
To a much extent we can say that pre-increment is faster then post-increment operator. If we talk about independent statement containing just pre-increment and post-increment operator then pre-increment is faster (without compiler optmization).but, if we talk about integer variable the difference is almost negligible.It would be one or two cycle in unoptimized c++ code.As with pre-increment operator we did not need temporary location to store value, value is directly incremented and assigned where as in post-increment operator we need to store value in temporary variable. So with data type like integer, pointers no major performance can be achieved but if we talk about classes one should prefer use pre-increment operator.
Lets try to implement both operator it would help us gain understanding about it :-
pre-increment operator
++i
int PreIncrement(int i)
{
  i = i+1;//incrementing i
return i;
}

post-increment operator

i++
int PostIncrement(int i)
{
  int tempvar = i;//temporary storage
  i = i + 1;//incrementing i
  return tempvar; //return tempvar
}


With above example its very clear that pre-increment is better and efficient then post-increment operator.
Again i want to make one point clear that it would not improve performance for data type like integers, pointer with advanced compiler you will not see any difference in assembly code too.I have written one test code to show this, lets look at it :-



int x =0;
001F361C  mov         dword ptr [x],0 
int y =1;
001F3623  mov         dword ptr [y],1 
x = ++y;
001F362A  mov         eax,dword ptr [y] 
001F362D  add         eax,1 
001F3630  mov         dword ptr [y],eax 
001F3633  mov         ecx,dword ptr [y] 
001F3636  mov         dword ptr [x],ecx 
x = y++;
001F3639  mov         eax,dword ptr [y] 
001F363C  mov         dword ptr [x],eax 
001F363F  mov         ecx,dword ptr [y] 
001F3642  add         ecx,1 
001F3645  mov         dword ptr [y],ecx 
y++;
001F3648  mov         eax,dword ptr [y] 
001F364B  add         eax,1 
001F364E  mov         dword ptr [y],eax 
++y;
001F3651  mov         eax,dword ptr [y] 
001F3654  add         eax,1 
001F3657  mov         dword ptr [y],eax 


With above disassembly code its clear that is no much impact on assembly instruction, code generated is almost same for both the cases.With all the analysis done so far, i am still thinking about post-increment operator.All points are going in-favor of pre-increment operator but there should be some benefit of post-increment operator too, where it can be used. Finally i found one such condition where post increment is better then pre-increment operator, lets look at following example :-
a) x = arrIntValues[i++]
b) x = arrIntValues[++i]

In above case expression (a) is better than (b) because in the second case,the address calculation  of the array element has to wait for the new value of i which will delay the availability of x for one or two clock cycles.But it should be used cautiously since if you are making such changes in programs it may change code behavior.

Time to conclude now. As we have seen usage and comparison of pre/post increment operator, which shows that both are equally good if used for primitive data types with optimized compiler option.For non primitive data type one should use pre-increment operator. And finally it depends upon your code condition too, as we have seen one condition where post-increment is more efficient then pre-increment operator.Whole discussion    is also applicable for pre/post decrement operator too.

Hope you enjoyed the post, Cheers,
-Tajendra




Feb 24, 2010

Sachin's record 200* In ODI vs South Africa, memorable milestone in cricketing world


I can’t stop myself writing on Sachin's 200, it’s a mmmmm what can I say just got spellbound from his performance.Its a magical mesmerizing memorable milestone performance from maestro the “Sachin Ramesh Tendulkar”.

Sachin slammed 200 not out today against one of the strongest ODI team South Africa at Captain Roop Singh Stadium Gwalior.




It’s a working day in our company and all are just busy with their scheduled work. And suddenly one guy screamed from his cube that “Sachin made 185 not out” this news just spreads like wildfire (technically like viruses on network). It infected almost every guy and all moved to our chill out zone which have television set. Quickly whole room got filled, each and every corner of room got occupied. All intellectuals who fights like anything in meeting rooms with their logical reasons were in total sync with each other and why not as all were  talking about the “Sachin Tendulkar”. All guys present in room had several positive comments on Sachin,
all were busy in proving that "They are the biggest fan of Sachin" and everyone in thier heart wanted Sachin to cmake first ever double century in ODI. 
Sachin crossed the magic number of 194 runs in 46th over and all went up clapping with a big smile on everyone's face.With this Sachin created a record of making a highest score in an ODI by breaking Saeed Anwar's record of 194 runs. But everyone was still holding breath eying for much bigger celebration.
Its now 47th over, Sachin reached 199 mark still requiring one golden run.We all were waiting for it and in next over we were hoping to see Sachin on strike but Dhoni faced all the 6 balls brilliantly and Sachin still on 199 mark :(. Despite Dhoni doing his job well, he was not getting any attention as everyone wanted to see Sachin on strike. And finally Sachin got strike in last over, Langeveldt the bowler, bowling 3rd ball of the last over, all stage set for Sachin to reach the milestone of double century. There was a complete silence in the room for a while, all praying for Sachin's 200. All were tensed but Sachin looking very confident and finally Langeveldt delivered the ball and Sachin guided ball for single run. All went up on their feet and this time celebration was much bigger and louder. Everyone were so happy and were feeling very proud. This moment will remain for a long time in memory of all the cricket lovers. 

This event was so big that when i entered "Sachin's 200" search string on google search, it fetched almost 2400 pages within minutes of his double century.
Sachin got more then 70 records under his name, for detail check this link :- 

Sachin is a living legend of cricketing world and adding to his greatness he dedicated this marvelous innings to Indian people.Sachin tussi great ho, jahanpanah tofah kabul karo :)




How to allocate memory dynamically on stack ?


I read some time back that memory operation on stack is much faster than heap. With this
information the first thing came into my mind was that if we get a way to allocate memory
dynamically on stack it would surely help us to optimize memory operation cost. I started
searching for it and finally I found one such way J.
Before going into its detail let’s take a look at dynamic memory allocation on heap.

Generally when it comes to dynamic memory allocation new/malloc  the well known calls
Comes into mind. They help us to dynamically allocate memory on the heap.

For e.g.
  int FunctionA()
{
   char* pszLineBuffer = (char*) malloc(1024*sizeof(char));
    …..
  // Program logic
     ….
  free(pszLineBuffer);
  return 1;
}

Above code would allocate 1024 bytes on heap dynamically. After the complete use of variable szLineBuffer, we
need to free memory also (free/delete can be used for it).  So, one has to  keep track of deallocation call,
else memory leak will get introduced.

Now coming back to our question, is there any way by which we can allocate memory dynamically on stack.
So the answer is yes. We can allocate variable length space dynamically on stack memory by using function
_alloca. This function allocates memory from the program stack. It simply takes number of bytes to be allocated and
return void* to the allocated space just as malloc call. This allocated memory will be freed automatically on function exit.
So it need not to be freed explicitly. One has to keep in mind about allocation size here, as stack overflow exception may
occur. Stack overflow exception handling can be used  for such calls. In case of stack overflow exception one can use
_resetstkoflw() to restore it back.

So our new code with _alloca  would be :-

  int NewFunctionA()
{
   char* pszLineBuffer = (char*) _alloca(1024*sizeof(char));
    …..
  // Program logic
     ….
  //no need to free szLineBuffer
  return 1;
}

Now let’s check out what will be the advantage of _alloca over new/malloc :-
1)      We have saved overhead of new/malloc.
As _alloca() got very little overhead of allocating memory on stack.
2)      No need to free memory explicitly. So, deallocation cost will be zero.
3)      If function like FunctionA() got multiple time in your program it may cause heap memory fragmentation on a long run,
Which would be saved with NewFunctionA() as stack memory never goes fragmented.


Now let’s check out what will be the disadvantage of _alloca over new/malloc :-
1)      One has to be cautious while using alloca for huge blocks.
2)      Its scope is limited to a function call.
3)      As stack overflow is not a standard C++ exception, one hast to use structured exception handling for it.


I hope you enjoyed this post.
-Tajendra



Feb 22, 2010

How to register Blog with google search ?

If you are a new blogger and want to get noticed on internet, then you can use google search engine for it.
Google search engine is the straight and most convincing way of attracting web traffic. Start writing good content , just be patient and surely your blog ranking will increase.

Follow below step to register it with google blog search :-

1) Got to link Goggle Blog Search. (http://blogsearch.google.com/ping)
2) Followin page would appear under it.


3) Enter your blog address into it.
4) Simply submit it.

Remember your page would not become famous overnight. It takes time and most importantly its your content which is your blog success mantra.

-Keep Blogging



Feb 21, 2010

Google Buzz started with Buzzing Issue (Breaking User Privacy Law). Is it a genuine issue or smart trick?



Google Buzz ?
The most buzzing event of Google nowadays and it’s also buzzing loud on all technical news too. Let’s find out what is so buzzing with it.

Google buzz is actually a smart way of short and sharper communication. The most attractive thing here is that it’s got integrated in your Gmail inbox, so don’t need to go onto some other link to access it.

Google Buzz is initiative toward getting strong in social networking domain. Currently Facebook covers almost 46% of the social network traffic, myspace 19% and you tube 14%. Google buzz can be said an answer to Facebook.

Google buzz comes with navigation in your gmail inbox. Buzz uses the people you email and chat with most often to build the first iteration of your network. This network was originally created by default and that is the biggest threat to privacy.Since Google buzz auto-follow people you communicate with on Gmail or Google Talk. Google buzz started with this issue and attracted lots of focus from the privacy organization. Many privacy organizations registered a strong concern over it. And Google buzz becomes the hot discussion topic of everyone. Every product tries to get focus with its new feature but Google buzz got the focus with its user privacy issue. Whatever Google buzz as a product ultimately attracted huge users and organization.
Finally Google apologizes for this and they have planned to launch it with more transparency and control features.It is still a mystery whether it’s all intended or a genuine user issue.

But overall Google buzz is a great feature to use; it helps one to share quickly text, videos and links with your network.
I have already starting buzzing with it and let’s see how far this feature will go.

Keep Blogging and Buzzing



Feb 20, 2010

How to register URL with search engines ?



Everyone wants to get noticed on Internet after launching very first content on new site :).
There are several ways by which one can get noticed on internet like search engines, backlinks, social networking sites, forums etc...I have explored search engine registration mechanism.
Its not very difficult to register your blog/website with famous search engine. Search engine are the most effective tool to get web traffic to your blogs/website. When it comes to search engine google, yahoo and msn live search are the most used option nowadays.





I have collected following links which can be used for submitting your URL :-
Above search engine shares 90% of all the hits. So registering to above link would be enough to get noticed at very first stage. Above links are easy mechanism to get yourself noticed, but they did not guarantee that your URL would come at top position in their searches. It all depends on the page rank, locality, back-links, content and several other factors, which guides search engines deciding priority of displaying pages.Let's have a brief of search engine working :- "Search engine have three basic module web crawling, indexing and searching.Web crawler collects information, then it get indexed based on several algorithms and searching retrieves relevant information from this indexed information".
I hope above information would be helpful if you are starting new website and want to to get noticed on internet.




Feb 19, 2010

JUGAAD .... creativity from Northern Rural India

In Feb' 2009 I went to a marriage in Uttar Pradesh near Hathras city. It’s a rural area of Northern India. No malls, no multiplexes, no super bazaars, and no four lane road all things are just as typical like Indian rural areas. But suddenly I noticed one strange thing running on road, its an open engine vehicle having enough space for loading goods. This vehicle had really made a mark in mine memory. By seeing such a strange thing how one can stop himself from asking -"what is this item actually? Why it’s running on road? Is it legal? Is it running with petrol/diesel "?
Pic. I have taken this JUGAAD pic near Hathras.


I started collecting information for this strange vehicle, and my curiosity actually got multiplied when i heard its name, it’s called as "JUGAAD”. Jugaad a typical Hindi word used for making things working in given conditions by hook or crook. Luckily i met a guy who was driving JUGAAD from past 2 yrs. I asked him to tell me about Jugaad, he said "Jugaad comes with a diesel pump engine fixed on a suspension of army jeep chassis and a loading platform at the backside." He had purchased it in nearly 50,000 Rs. Jugaad price can vary between 50,000 - 85,000 Rs as it comes with variation like branded engines and tyres. When i asked him about license of Jugaad, he said "Jugaad has no license, no registration, and no other automobile standards constraint. All are so used to see it that nobody actually objects and to keep away cops we used to bribe them".
Jugaad is really serving many people livelihood in rural areas as they are used for carrying peoples (like city vans, jugaad can be seen carrying 30-35 peoples), loading crops from fields, loading fertilizer, seed and any kind of medium sized load similar to Mini Trucks. With Jugaad one can earn 5000-10,000 Rs per month. In Northern India, it’s one of the cheapest mode for mid size transportation.
Seeing JUGAAD one can’t ignore the creativity coming from rural India. They have very rightly developed a cheap alternate for costly four wheeler options present in Indian Market. On same lines one more name is coming to my mind, which Tata's Nano. It’s also a very creative approach towards making facilities available to common man. Jugaad is an iconic discovery of rural India, which really inspires us to thing radically.
Jugaad teaches us that invention did not need a huge setup, complex equations, sophisticated labs etc... But it needs only simplified and clear thought in right direction.



Feb 18, 2010

Parallel Thinking......A constructive conclusion tool

The approach is called as “Parallel Thinking”.

"Parallel thinking" means that at any moment everyone is looking and thinking in the same direction. There is no attack and defense.

There are six modes of thinking. Each mode is symbolized by a colored “HAT”.








So when the Black Hat is in use, everyone is focusing on possible dangers, weakness faults, etc..
When the Yellow Hat is in use everyone focuses on benefits and values.
The Green Hat is for creativity and new ideas.
The Red Hat is permission to put forward emotions, intuitions and feelings - without any need to justify them.
The Blue Hat is the organizing hat.
The White Hat is on information.

Its ultimate benefits:-

Suppose someone is against an idea being discussed. Normally that person would use every moment and every bit of intellectual energy to point out the faults in the idea.

With the Hat system, that person would be fully encouraged to be cautions under the Black Hat. But when the Yellow hat came around that person would be expected to find values.
If that person was unable to find values while everyone else did find values then that person would be seen by everyone to be "stupid".
If the values are there, why can you not see them ?


Its like human software for formalizing thinking. We can customize it with our need to.


Concept taken from :- "Book:- LATERAL THINKING Author :- EDWARD DE BONO"



What is Blog ? Fun, Money, Passion, Award, Dream

Blog : What exactly blog is ? Blog basically refers to an organized "web logs" i.e. storing any type of data on web any time. This log can be published on internet, to make it visible to desired users.

Lets try to eloborate Blog in a way acronyms does , it can be
Beautiful List of Organized Gesture,
Best Literature of Ordinary Guys,
Blast of Last Opera Group,
Breaking Lines with Oozing Guts,
Building Leagues of Outstanding Gallants,
Blossoming Life by Omitting Grudges.

We can easily map ourself to one of the catogeries from above acronyms. Now lets look at another perspective of blogs, why we should write bolgs. If we try to find answer to this question we would surely get diffrent answers from diffrent people. I ask this question in much simpler way to my friend who is a property broker, he said "i want to make a blog which would help me to attract customers intrested in property". when i asked this question from a techie guy he said "i want blog on technical domain". Then i asked same question to a guy who was searching job , he had not shown much intrest in it and said "if i get a job of blogger then only i would blog". Asked same question from one of my friend who is not working and dont want to be, she said "i want to blog about my dreams". Listening so many thought on one web log is actually the success mantra of blogging. Blog really help one to think about his/her desire which he/she can express without any constraints.

One can blog on anything and most importantly anytime. Like i am doing :).
Lets now check purpose of blogging, it can be for pure Fun , Money, Passion, Dream , Hobby etc....
What i can say here is :- To blog "blog" one should have to blog in a blog way. Its really intresting if thought in construtive way. Word blog can be used as noun or verb, blog word was coined by "Peter Merholz".
Blog is customizably extensible, like one can create collabrative blogs too. Blogs became so much popular nowdays as many communities offers Award to good blogs. Among the major blog awards are The Weblog Awards (Bloggies) , and the BOBs (Best of Blogs). Like usual film or television awarding committees, blog awards are started by a certain body, usually composed of blog enthusiasts.

There are many sites that offer free service and account creation for blogging.
Lets have a look at them :-

Wordpress.com: http://www.wordpress.com/

•Very professional-looking templates, easy to use.
•More limited than others, like Blogger. You can't play with your template.
•You can categorize your posts with custom categories and tags.

Blogger: http://www.blogger.com/

•Lots of easy template integration, custom themes, gadgets, html etc.
•Not perceived to be as professional as Wordpress or some others.
•You can categorize your posts with labels.

LiveJournal: http://www.livejournal.com/

•This is more community-centric blogging, including Friends lists.
•You can categorize your posts with tags as well as your mood, music, etc.

Vox: http://www.vox.com/

•This is more community-centric blogging, including Friends lists.

Xanga: http://www.xanga.com/

•This is more community-centric blogging, including Friends lists.

MySpace: http://www.myspace.com/

•This is more community-centric blogging, including Friends lists.

Facebook: http://www.facebook.com/

•On Facebook, you can have "Notes" which are viewed by your friends.


As we have some basic information about blogs, hopefully term Blog is more releavent now.
So start blogging if you have not started yet and those who have keep Blogging :).



Feb 17, 2010

Starting my "IDITAROD"



IDITAROD: - I
t’s the Dexterous Initiative Towards Aggregating Radical Orientations from Diversity.

Starting my blog with tilted “IDITAROD”, it’s amongst the toughest race on earth. Very motivational and inspiring trial race, every time it shows new Orientations. So, thought to begin with it. If we observe this race, it will surely help us in Dextering our skills.

Let’s take a brief of it; The Iditarod is a dog sled race that takes place every March in Alaska. It is sometimes called the "Last Great Race." Although the race is over 1150 miles long, the race is officially 1,049 miles, since Alaska is the 49th state in the USA. The Iditarod trail goes from Anchorage to Nome. There is a northern route and a southern route; these are used on alternate years (north in even-numbered years). The race starts on the first Saturday in March and takes about 10 days to complete. The winning musher (dog sled racer) takes home a large cash prize; the last musher to finish the race extinguishes (and wins) a red lantern at the finish line.


This race can be easily mapped to our life. If we sketch all phases of this event we can easily draw out many constructive conclusions, which will serve us in various practical situations. I really liked the challenges observed in this event. It’s not just physical challenge but it test mental level to the last extend.


Most of the times we give excuses, not able to think because environment is not good or its
noisy, clumsy etc...But people who participate defines their strategy at runtime despite of extreme conditions, they are really like Martians. Extreme conditions of this trial include freezing temperature, which can easily cause frost nip and even frost bite in simplified term it’s like losing skin sensation and skin live cell destruction. These are situations in which the body has made the decision to risk or sacrifice some of the more expendable regions to preserve the core temperature and so avoid death from hypothermia. Huh it’s really tough.But a real applaud to all the mushers for their die-hard effort.Normal person can think only of his or her survival in such scenarios whereas mushers compete there. At last i want to mention one famous quote to end this, which goes like :-






"Some are born great, some achieve greatness, and some have greatness thrust upon 'em"


Starting my "IDITAROD" :) ......