Sunday, July 22, 2012

Preparing for an online test for placement !

The anxious evenings, the nights when you know you should be sleeping but you just dont, the nervous mornings – must admit those were some of the best days of my life. Don’t you agree ? I guess I can safely assume,  almost all of us have been told by our parents that we should have a sound sleep when we have an exam/interview or any such thing the next day. The fact is we never do :D. After all, we engineers are habituated to working only at nights! My juniors at college have their first exam relating to placement tomorrow. A few of them have been in contact and it was a pleasure helping out some of them. I hope it helps :P. Whatever it be, I am able to live my own life an year earlier through them! And I am really thankful to them for that.

Getting back to point, this blog is meant to be a guideline for some of them. These days I have been getting a lot of e-mails regarding what one should study when an “xyz” company visits college and things like that. Hence, I decided to come up with this post to share my own experience of it. I would further like to add that I was always aiming to become a software developer and I guess the contents mentioned below would better suit someone like that. I understand that this is not the best and  also welcome better points from some of my colleagues ! Trust me I am not diplomatic about that :P.  Here are a few things I did the night before a written exam (relating to placement) in my college days :

  1. Almost all firms, for some reason, go for an aptitude test. And it is a very good practice to have some practice of it before you appear for a written exam. I personally had solved R S Agrawal’s text. I also loved taking a few aptitude tests at indiabix.com on the eve. They offer you a certain number of questions and put a clock with 30 minutes of time up and running . This helps simulate an exam like atmosphere and identify any issues relating to management of time. I definitely had issues with that !

  2. Next comes the MCQs(multiple choice questions) based on understanding of C/C++. I would suggest doing “Test your C skills”. Its an excellent text and I would suggest you to grab a copy of it.

  3. Sometimes, pointers are an issue. Actually most of the time they are! I personally used “Understanding Pointers in C” for that. The exercises for that.

  4. Kerninghan & Ritchie (K & R)’s text called – “The C programming language” is something you just cant miss out.

  5. I am also a cormen fan, but I wont suggest that for the night before. Its voluminous! Though I used to go through some sorting algos sometimes.

  6. Operating System Concepts next- I would say- Its not possible to go through it the night before. I personally loved two textbooks. First, the Galvin’s and then Tennenbaum’s. I had finished the first one cover to cover in my summer vacations. Plus, if you are a video lecture fan, you may also opt for lectures of Prof P.K.Biswas (from IIT KGP) or video lectures of Berkley University. I had gone through both these videos lecture series. But I guess this was too much for I was really interested. For the night before I would suggest two questions. First, what is the difference between a process and a thread. Study it in detail. Secondly, have a good understanding of semaphore variables. Additional topics include memory management, the concept of virtual memory, paging segmentation etc. and deadlock if time permits.

  7. Networking Concepts – Try to remember all 7 layers in OSI protocol and 2 protocols that operate in each one of them. Additionally one may also go through routing, IPv4, IPv6 etc.

  8. If it is a database related company, I would suggest going through the following topics:



  •         Basic SQL queries,

  •         Joins on tables,

  •         Normalization,

  •         ACID property (These look simple, but there is no end to it.)


The above points have been written keeping in mind that the applicants are freshers. I am myself just that and thus cant say anything for those who have some experience in the software industry and want to apply for a job. Last, but not the least, If you have reached this point of the post, you deserve a best of luck too! And yes, above all a sound sleep is really helpful.

Sunday, May 6, 2012

Wireless charging of mobile phones !

With the Samsung's new release Galaxy S3 , a lot has been going on in the news. Though being an undergrad, I find it a little difficult to fit into my budget there is no denying that it is a beautiful device. If Samsung is to be believed this device is "inspired by nature – it sees, listens, responds, and allows one to share the greatest moments." You can find a look and feel of it here. They have also given a lot of snapshots and performed many a comparisons with galaxy S and  S2. Have a look at the  features yourself.

One talking point about the device has been the support for wireless charging. Dont you hate the mass of wires that comes out of the plug-point from a corner of your room? I'm personally annoyed with it. Not only it occupies some space in my room, I have also stepped on the pin of my mobile charger that gets into my phone a couple of times and trust me it cant take any more blows now. Is there a way out ? Well,now there is ! It may soon be a thing of the past. Coming back to S3, it doesnt provide you with the wireless charger, they ship the device with the normal wired charger we have been using. But, you can get a wireless charger separately and your phone will support it.

Lets get to some technical stuff now. How does it work actually ? Among the engineers and scientists, its called inductive charging. Below is a picture from wiki to illustrate the same.



There are two smart coils namely- primary and secondary. The primary coil is associated with the charger and a magnetic field is set up around this. When a mobile device is present in the area with magnetic field generated from the primary coil, electricity is transferred to the secondary coil available in the phone and this power is used to charge the battery of the device.

If you think this is a completely new idea, you might be mistaken, for it is not a new innovation by samsung. It has been used in past as well. According to times of India, Palm adapted the technology three years ago and sold a charger called Touchstone that allowed phones like Pre and Pixi to be charged wirelessly. They used it in a large number of their products. Powermat too sells such chargers that can be used with iPhone. You may wonder, if this technology is three years old, shouldnt it be very famous by now? Actually, its a little under-developed. The range covered is not great and people are forced to place their mobile phones on top of the wireless chargers as shown in the picture below:



Mobile phones are not the only device that can be charged this way. Its a long list. Recently, Telegraph reported the following:

Fujitsu, the Japanese technology company, has created a system capable of simultaneously charging multiple portable electronic devices such as mobile phones, digital cameras and laptop computers without the need for cable connections.Electric cars users may also eventually be able to charge their vehicles wirelessly using the same technology

Saturday, April 21, 2012

A faster approach to YOUTUBE

Its a common issue for we guys at college in our part of the world to see our Youtube video streaming at a very slow speed. Youtube, no doubt, is an excellent platform but a slow connection hampers the experience by a great deal. Its frustating to wait for the video to buffer. The Youtube page contains a lot of information such as similar videos, comments, likes plus a few thing relating to privacy, safety, bug report etc at the bottom. Thumbs up for that for I love having options at hand.

But then, I sometimes wonder- "Are we the only people with a slow connection ?".  Wont it be nice in such a case to limit some of  the youtube features to get the video buffered better ? After all, its the video which one tunes into Youtube for, others  just play a supporting role. I , for sure, maintain that, for these features are of no value to me if I cant get the feel of a video and I expect Google to understand that and give me some control over this issue. I am a big Google fan and always expect their products to be of excellent quality with a lot of power to the users. But then do I have an option here ? Yes, I do !! I was just going through web trying this afternoon and came across something called Youtube Feather.



Have you heard of it ? If not, spare a minute. Give it a try. You can try it out here. If you want to know more, you can also look at a 1 minute video of it at youtube itself. But then, what goes on at the back is just what I mentioned earlier. Its a trade-off between the speed at which your video loads and the features you want. Youtube feather limits the video suggestions to 5 as opposed to 21 normally and the number of loaded comments to 10. The video is of standard quality (no option to upgrade to High quality exists). In addition to these, Video replies, real-time sharing, and auto-suggest from YouTube's search bar have also been cut down. And the biggest trouble I think is that it cant play all the videos. Though I have not found such a video yet, I have read the same.

Probably, that is the reason its not very popular as of now, but then as always I am excited about this feature from Google. Take a tour of the Google blog though if you want to have a look at the figures on how effective is it after all.

Friday, March 30, 2012

The SIMPLE homepage @google.com, why is it so designed ?

White, to me,  is the favourite colour for it  projects purity, cleanliness, and neutrality. Doctors don white coats, brides traditionally wear white gowns, and a white picket fence surrounds a safe and happy home. White is clean, neat and classy and looks pleasing to the eye. But is it the reason why the google homepage is also white in background. What does it project about Google ? What message does it convey ?

Ever Wondered why the google homepage is such a simple one ? No flashy looks, nothing moving here and there, no ads, absolutely nothing more than the simple plain search! You would probably guess that its a well thought move , definitely a deliberate decision. Of course, we dont expect the big G to be casual about it for its an unmatched web giant. Is it because they didnt have people to design it more elegantly/appealing ? Sounds kind of funny ! Right ? Well, it isnt !

If Google's vice president of local, maps and location services, Mayer is to be believed, this is a result of the limited knowledge of the co-founders of Google. This is what Sergey Brin had to say to Mayor when enquired about it. His own knowledge of HTML was not that great and they did not have webmasters, plus they wanted to test their search technique quickly which they were pretty confident about.

Some argue that it could have been more user friendly and needed less clicks had they put more options , more graphics on their homepage. To some extent I do agree with them, but then i personally feel its an iconic page with a neat look. Almost all other pages on web are a little more cluttered and most importantly we are used to this plain simple look which by now looks so pleasing to the eye. To me its a classy choice to keep it this way. What do you think though?

Sunday, March 25, 2012

Internship or no internship ??

"Should I go for an internship ? " - I have been asked this question a number of times these days and I could never reply it as a yes/no. Probably it depends. But depends on what ? To some I replied - "Yes go for one if you find an opportunity ", to some I could not give a concrete answer. Probably I was not sure. The reason is - my friends and colleagues have a divided opinion on the matter. One thinks, "Why go for an intern ? Instead one should sit at home and enhance his skills." Other said, "why cant one enhance his skills while he is an intern ?" And many others are not that clear about it. So you see that is the problem !!

Interns can sometimes be very useful. There is no denying the fact if you get to intern with an excellent firm. If not, you got to think hard and decide. Interns can be rewarding or sometimes not, sometimes they are paid, sometimes not. But I personally think the money factor should not be a very big role in this decision. It should be more about the time you devote and things you learn. Here is a small story.

Have you heard of  Wes Cherry? Probably not ! Have you played Solitaire on windows ? I think I can safely assume you have. If not, find a computer near you that has windows. Go to start up ->games-> solitaire. This is it !! It has been a part of windows operating system since windows 3.0 itself. Windows 3.0 was released in 1990 and I guess it has always been a part of it since then.  Why are we talking about though ? Yes, lets get back to the point. Solitaire was wrote (developed) by Wes Cherry in 1989 while he was an intern at microsoft. At that time there were few games and this became immensely popular. To verify how popular and tempting it has been let me tell you that people have also been caught playing Solitaire in their offices and some of them fired too :P . Dont believe that ? Look here yourself. To his misfortune though Wes received no royalties for Solitaire. So internships can sometimes be not rewarding at all . But then they are pretty useful. In wes's case itself, he later got an opportunity to write some code for the "microsoft Excel"  and yes he was highly rewarded for this.

The moral of the story is - though you could not be rewarded for your work as an intern it gives you a great opportunity to get a full time job with the same firm and enhances your chances to get selected into some other firms as well.

I myself did an internship at IIT Bombay in 2010. It was a 6-week internship and to this day I cant believe I wrote such a huge volume of code. I was a part of the team (of 5 people) who developed an excellent software. It was there that I realized how much I loved this field of software development. Not only that, I realized for the first time how important testing and UI (user interface) design are !! Though I can still not decide whether I should advice you to go for an internship or not, I think you should go for it. Take a chance, work hard, put in extra hours and I bet it will definitely benefit you in the long run :)

Last, but not the least, if you dont get an opportunity dont be disheartened. Trust me, I have seen a number of people bagging an excellent offer inspite of no internship/good projects. But yes, in that case you will have to work just a little harder.

Monday, March 19, 2012

The encyclopedia or wiki, the text or the e-book ?

Its been just a few days since I appeared for a job at amazon, and as usual I went about reading a lot about the company. One interesting product of theirs which specially captured my interest was kindle, the e-book reader which enable users to shop for, download, browse, and read e-books, newspapers, magazines, blogs, and other digital content. Look at the contents in bold once again. A few years ago, we were so used to the hard copies of these. An amazing sale of the amazon kindle made me think twice about the digitization of all the information around us today. It has occurred so rapidly that we could never sit back and admire it. So what ? Whats new then ? Here it is..


The encyclopedia called Britannica has decided to stop the release of its printed versions. Its going completely digital now.


And this makes me think of the future of libraries. What will be the most important  sources of information in future? I can already see a trend in my friends. People seeking knowledge no longer visit libraries, they no longer refer the Encyclopedia placed at a shelf in the library. Wikipedia and co I think has brought about this change. The online tool and e-content is so comfortably accessible, maintained and updated which probably beats the feeling of having a book in your hand !!

To many, it would be a shocking news, and I can understand that for I too love the feeling of  having a printed book in my hand as opposed reading an e-book. But, in life the only thing thats constant is "the change". And I think we are moving towards an age where most (if not all) of the information will only be available in the digital form !!  The printed pages of  Britannica have been a great companion to many for over 244 years and so this change will surely bring sadness to some. But with the tremendous rate at which digitization  is taking place it’s an inevitable move in this golden age of Internet and technology. If you are a Britannica fan and not the print form itself, nothing is going to change. Its only going to get better, at least in terms of regular updation. Jorge Cauz, the president of Encyclopaedia Britannica, Inc. put it like this -
 it [the digital form] is now a better tool since the website is updated on a regular basis and is integrated with multimedia. Their online offerings are more expansive which will make it even more convenient when doing researches.

Lets now look at the other side of the story. With this move, is it justified enough say that wikipedia is going to rule the world of information soon ? Thats probably debatable !!


The wikipedia contents can be very easily changed into a nonsense. Though generally not the case, its still possible. Add to that the censhorships, Is wikipedia really as reliable as an encyclopedia ?? Not exactly, but studies have shown that its not far behind. For more on this comparison, you may look at a report on the comparison between wikipedia and Britannica. To me it appears that Wikipedia is a definitely a good starting point for an introduction into any topic, to say the least. If you still doubt the credibility of the contents at wikipedia, it does provide you with links to outside sources. It also saves a lot of time compared to going through a gazillion Google hits for something useful. All these references on wikipedia are mostly excellent ones.


Five years ago, I lived with my uncle. When he got up in the morning in winter, my aunt used to place a cup of coffee and the "Times of India" newspaper near him. As soon as he got up he would pick up the two and then start with his normal routine. For some reason though, I started dreaming of it for myself :P but in my case I guess  it will be a little  different to say the least, for I have already stopped the subscription of Times of India (the newspaper) and moved to the e-version. Whats your take though ? Do you think the feeling of having a text in hand will be obsolete soon ?



Wednesday, March 14, 2012

Wikipedia NOT with Go daddy now !

How often do you visit wikipedia ? Have you heard of SOPA/PIPA ? Did you notice the wikipedia blackout on January 18 ? Do you know what the reason was ? Here it is - the full story on why wikipedia took this bold step, what followed and what has changed !!

What is SOPA/PIPA ?

SOPA stands for "Stop online Piracy act" and PIPA represents " The PROTECT IP Act ",  with PROTECT meaning Preventing Real Online Threats to Economic Creativity and Theft of Intellectual Property Act. SOPA is a bill introduced in US to expand the ability of their laws to fight online trafficking in copyrighted content on web. Under this act if a person/organisation finds that a website on internet is using its content without a legal permission from them, they can approach a court and get orders to stop the advertising networks and payment facilities from conducting business with this websites. They can get the site blocked and search engines will thereby stop linking to that site. Not that there were no such laws earlier but SOPA strengthens them by a fair magnitude. PIPA is a similar bill. Like SOPA, PIPA too gives the the copyright holders a strong tool to stand against a dishonest website.

Piracy indeed is a big concern but whether or not this is the right way to curb it,  is debatable. Some have lauded it, others have deemed it too harsh on the websites involving user generated data. Some have welcomed it with both the hands open. But it is not short on the criticism too. You can find a list of Congresspersons from US on each side and their views on these bills hereEric Schmidt , the Google chairman,  put it as an "overly simple solutions to a complex problem". 

The case of websites with user-generated data:

Though piracy, no doubt, deserves a strong fightback and copyright holders have been crying for long asking for a strict rule to help them curb this dreadful virus, people have found the above laws a little ambiguous to say the least. The case of websites such as Facebook, Youtube, Vimeo, twitter etc is interesting. Users leave a lot of content on these websites and users, I am not sure ought to be restricted . Let us take the most familiar example of Youtube. People post a lot of videos on Youtube. It may be the video of an artist who performed at their college and they would love to share that with their friends through youtube or probably Facebook. "Jal- the band" , performed at my college recently (by the way, thanks to those who organised it :D) and would you not love to share such a thing on your Facebook profile ? But wait a minute, should I get a legal permission from the officials at "JAL"  before I post a video of it on my Facebook wall ? Now suppose, I always go that way. Will I post as many videos as I normally do ? Will I not sometimes think - "what drama man !! Who will do all that ? I am feeling quite lazy about it" (Well, I am a lazy person by the way !!). Will that not be a setback for Facebook ??

Now suppose one posts such a thing on his Facebook wall or may be writes something on Wikipedia which should really require a copyright. What do you think the result should be ? Should he be banned from using the respective site ? Or do you think thats a little too harsh ? If you do, this is going to be a surprise for you. Now look at the underlined text above. Yes, the organisation with the copyright can get facebook (Youtube or wikipedia) blocked. Its not mendatory that this will happen but there is a chance (even though slim) that this can happen.

What happened between Wikipedia and GO Daddy:

Wikipedia blackout on January 18,2012 was a firm stand by wikipedia against SOPA. Now, look at the image below. This is a snapshot showing a tweet by Jimmy wales (the wikipedia co-founder) himself:



As the above text suggests Go daddy seems to have supported SOPA and Wikimedia could not digest this. Wikimedia legal counsel Michelle Paulson put the transfer of its domain registry like this:-
After months of deliberation and a complicated transfer, the Wikimedia Foundation domain portfolio has been successfully transferred from GoDaddy to MarkMonitor [a U.S.-based domain registry and trademark ]. The portfolio transfer was formally completed on Friday, March 9th, 2012. The transfers were done seamlessly and our sites did not experience any interruption of service or other issues during the procedure.

Here is the official blog post covering the transfer. Wikipedia is not alone on this. If VentureBeat is to be believed, Go daddy has lost more than 37,000 domains as a result of its support for SOPA . Though, Go daddy realised this and softened its stand on SOPA, it was just a little late. I am not completely against SOPA. I completely agree that piracy need to be fought and fought very strongly but i think the bill just passed needs to be edited a little.

Related Articles:

Wednesday, March 7, 2012

Watson computer - the INTELLIGENT one !!!

The human-like intelligence- ARTIFICIAL INTELLIGENCE !!

Can a machine be intelligent ? Can it talk to people in their natural language ? Can it read our lips ? Is it possible to build a machine as smart as a person ? Can the human intelligence be replicated ? Can we build a person ? or does it only confine to fiction ?  The question has been floating for decades but without a concrete answer !!  The computer has always been the king when it comes to processing huge amount of data/information.The immense rate at which it has grown inspires the confidence. The confidence is high enough to at least inspire a lot of characters in fiction.  The concept looks mesmerizing but no computer/robot has been able to interact with human as seamlessly as hollywood imagines. The problem is - the human brain, a very complex entity that defies any attempt at replication. Our brain is immensely sophisticated. The simple skills that humans master early in life like understanding language or recognizing objects continues to baffle the researchers.

The quest for artificial intelligence has gone on for decades. There is a huge difference between data and information. Computers process data but can they extract information out of it ? Can a machine possess knowledge ? Can it learn from experiences ? These are questions that decide if a system is intelligent. Lately there has been a lot of research in the field of artificial intelligence and machine learning. But no machine can understand natural language and converse with a human for it includes puns, irony, riddles and double meaning sentences. There has been a lot of work to achieve it and this article looks at one such attempt. An attempt by IBM.

The Chess Playing Computer:

You might have heard of Deep Blue- the chess playing computer !! It was an initiative by IBM. If wikipedia is to be believed, On May 11, 1997, the machine won a six-game match by two wins to one with three draws against a world champion in chess- Garry Kasparov. The system derived its playing strength mainly out of ts brute force computing power. It was capable of evaluating 200 million positions per second. Computing at an extremely high speed it could evaluate multiple steps and search the step that would result in maximum chances of winning or minimum chances of loosing. There were adverseries who argued that the rules of chess are very well defined. So it can easily be coded in a computer system and this in no way means that the system was intelligent. Thanks to these people IBM came with a better system- The Watson Computer!!

The motivation Behind the Watson computer:-

Its an interesting story that led to the thought of designing this system. Watson computer was designed to play Jeopardy!. Jeopardy is a unique quiz-show in which there are three contestants. They are given clues leading to an answer and the contestants are required to guess what the question would be !! Sounds kind of interesting. Right ?? The show features trivia in history, literature, the arts, pop culture, science, sports, geography, wordplay, and all other topics. To know more about Jeoprady! you may visit the wiki article or watch a television show of it on youtube.Getting back to Watson,since Deep Blue's victory over Garry Kasparov in 1997, IBM had been on the hunt for a new challenge. Once Charles Lickel went out for a dinner with his coworkers. There he noticed that the restaurant they were in had fallen silent. The cause of this was the airing of a show on television featuring: Ken Jennings, who was then in the middle of his successful 74-game run on Jeopardy!. He thought of quiz show as a possible challenge for IBM, and passed the idea on. In 2005, IBM Research executive Paul Horn backed Lickel up and David Ferrucci took the challenge.

What is Watson ? What is it capable of ???

According to IBM, Watson is an efficient analytical engine that pulls many sources of data together in real-time, discovers an insight, and deciphers a degree of confidence. Lets analyse this definition. You can pose questions/hints and watson will search the most relevant things for you. Is that not what the search engines do ? The point is, watson takes you a step further. Watson can understand the actual meaning behind words, distinguish between relevant and irrelevant content, and ultimately demonstrate confidence to deliver precise final answers. As a result of its deeper understanding of natural language, it can process and answer more complex questions that include puns, irony and riddles common in natural language. Look at the words in bold. Yes, thats exactly how it differs from your favourite search engine. Ask watson- "What is the capital of Russia?” and it will speak out - “Moscow,” . As simple as that !! Now think of your search engines. Ask them the same- What is the capital of Russia?” It’ll award you with links to websites where you might find your answer.You then revise your search terms until you find a satisfactory answer. Woludnt it be nice if you could just ask the question, and get an actual answer rather than a list of documents or websites? Thats watson !!!

Watson- the Jeopardy Player:

Is Watson an improved search engine ??  No, it was never meant to be one. In 2011 Watson did what it was supposed to, it played the game of Jeopardy! with Ken Jennings and Brad Rutter, two of the most successful contestants on the show and emerged the winner too. Watson learns through machine learning, it learns from its mistakes, for example, initially it used to come up with very silly answers- some of which one can never expect out of a human. As part of the preparation, IBM constructed a mock set in a conference room at one of its technology sites to model the one used on Jeopardy! Human players, including former Jeopardy! contestants, also participated in mock games against Watson. This helped it learn a lot about the game. Due to its limitations with audio/video understanding, Watson received the clues as electronic texts at the same moment they were made visible to the human players. It would then parse the clues into different keywords and sentence fragments in order to find statistically related phrases.Watson's main innovation was not in the creation of a new algorithm for this operation but rather its ability to quickly execute thousands of proven language analysis algorithms simultaneously to find the correct answer.The more algorithms that find the same answer independently the more likely Watson is to be correct. Once Watson has a small number of potential solutions it is able to check against its database to ascertain whether the solution makes sense. Part of the system used to win the Jeopardy! contest was the electronic circuitry that receives the "ready" signal and then examined whether Watson's confidence level was great enough to activate the buzzer. Given the speed of this circuitry compared to the speed of human reaction times, Watson's reaction time was faster than the human contestants except when the human anticipated (instead of reacted to) the ready signal. After signaling, Watson speaks with an electronic voice and gives the responses in Jeopardy!'s question format. Watson's voice was synthesized from recordings that actor Jeff Woodman made for an IBM text-to-speech program in 2004. You would think is it only for a game that IBM spent all its time and money ? No, Jeopardy! was only a showcase of IBM's work in the field of AI.

The Science Behind an Answer:

The science behind formulation of answers by Watson can be thought of as a 4-step process:

  1. Question Analysis: Watson parses the question into parts of speech and identify the different roles words and phrases are playing. At this stage Watson has no idea of what the question can be. So it increases its chances of reaching the right one by considering many different options about what the question may be.

  2. Hypothesis Generation: For each interpretation of the question, Watson goes through millions of documents. At this point quantity is important as it does not want to miss out on reaching the correct reference. If it does, it can never chose the correct answer!!

  3. Evidence Scoring: It is not enough for watson to just come up with an answers but it has to support them with evidences and logic. Thousands of algorithms run in parallel to evaluate the score for each possible answer.

  4. Final Merging and Ranking: The scores are then used to rank the possible answers and evaluate the confidence watson possesses in its highest ranked answers. Note that the threshold confidence level based on which Watson decides whether it should give an answer or not is not fixed but depends on the scores of its opponents and the situation in the game.


What future has in store for Watson: 

Watson cant understand the love of a mother, the feel of music, the emotions but his enormous knowledge base, his skill to understand and interpret the natural language and his ability to learn are definite signals to a marked achievement in the field of technology. Watson is impressively intelligent. Beyond Jeopardy!, the IBM team is working to deploy this technology across industries such as healthcare, finance and customer service. In the words of Dr. David Gondek form IBM:
U think of internet. No one knew that internet would become such an important part of our life. Watson has a similar promise. It is transformative and you dont even know what it can become.

The whole project was not about Jeopardy! , it was about doing research, its about doing deep analytics and natural language understandings. Its about applying the technology to solve problems people really care about. According to IBM, "The goal is to have computers start to interact in natural human terms across a range of applications and processes, understanding the questions that humans ask and providing answers that humans can understand and justify." Nuance Communications Inc has partnered IBM in the research project to develop a commercial product that will exploit Watson’s capabilities as a clinical decision support system to aid the diagnosis and treatment of patients. Physicians at Columbia University are helping identify critical issues in the practice of medicine where the Watson technology may be able to contribute and physicians at the University of Maryland are working to identify the best way that a technology like Watson could interact with medical practitioners to provide the maximum assistance. It has also been suggested by Robert C. Weber, IBM's general counsel, that Watson may be used for legal research. Just the same way Watson analyzed massive data in Jeopardy! to reach a set of hypotheses and list down couple of most likely outcomes, it could help Doctors in diagnosing patients. Watson could analyze the patient's specific symptoms, medical history, hereditary history and synthesize that data along with the mass of all unstructured and structured medical information in the world including (but not limited to) medical records of similar situations available to it. Watson uses this information in addition to the wealth of fundamental medical knowledge available in the form of all published medical books and articles fed into Watson. IBM had made it clear that Watson did not intend to replace doctors, but assist them to avoid medical errors and sharpen medical diagnosis with the help of its advanced analytics technology. IBM intends to use Watson in other information intensive fields as well, like telecom, financial services, government etc. To end with, I would say this is not the end of the list, but the beginning of an era and


Now, do you think its the Golden Age of Technology we are living in?

References:

Monday, March 5, 2012

Edit distance - implementation

The Problem Statement:

Edit Distance (also called Levenshtein distance)is a classic Dynamic Programming Problem. You are given a source string (say, of length m)and a target string (say of length n) plus a series of allowed transformations and their corresponding costs. You are required to find the minimum cost required to convert the source string into the target string using only the given transformations. Let us take a temporary string "temp" to illustrate things clearly. Initially we will keep our "temp" string empty and at the end of the algorithm we will have "temp" containing the same contents as the target string. Lets use i and j as the indices into the source string and the "temp" string. Set i=j=0 initially. The allowed transformations are generally:

  1. insert - add a character(say 'c') to the "temp" string ie.. put temp[j]=c and increment j.

  2. replace - replacing a character of source string by any another character (say 'c') ie.. we will insert c into "temp" string and increment both i and j. Note that we only incremented j in (1).

  3. delete - deleting a character from source string ie.. increment i only.

  4. copy - copy a character from source to "temp"(generally involves no cost).


Cormen's text (no 1 here) also mentions this problem in its exercises but he has given two more transformations called

  • twiddle - exchange next two characters ie.. copy both but they appear in opposite order in the target string.

  • kill - kill the remainder of source string ie set i=m-1.


Lets assume that the costs for copy, insert, replace and delete are C,I,R and D respectively.  Also, for simplicity we will leave out the "twiddle" and "kill" operations. If you want to consider these two operations, you may refer the Instructor’s Manual by Thomas H. Cormen, Clara Lee and Erica Lin to accompany the cormen's text which gives the pseudocode involving "twiddle" and "kill" functions as well. Lets now look at a few examples to understand the problem statement more clearly.

Examples:

  1. Let source string="at" and target string="mat". Here we can simply insert "m" at the beginning of "temp"and then copy 'a' and 't' from source to "temp". So the minimum cost required= I+(2*C)

  2. let source="cat" , target = "mat" then cost= R+(2*C),

  3. let source="cat" , target = "at" then cost= D+(2*C),

  4. let source="cat" , target = "cat" then cost= 0(zero),

  5. let source="cat" , target = empty string, then cost= 3*I ie.. insert all 3 characters.


As is generally the case , lets assume that copy operation requires no cost.Lets now take a slightly tougher example(from wikipedia article):

Suppose, source= "kitten" and target="sitting",there is no way to do it with fewer than three edits:

  • kitten → sitten (replace 'k' by 's')

  • sitten → sittin (replace 'e' by 'i')

  • sittin → sitting (insert of 'g' at the end).


Recursive Code:

Below is a recursive code to find the edit distance of two given strings. You may try different inputs on the ideone link for my recursive solution.

[sourcecode language="cpp"]

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define IC 1 /*cost to insert*/
#define RC 1 /*cost to replace*/
#define DC 1 /*cost to delete*/

int minimum(int a, int b, int c)
{
int min = c;

if( a < b )
{
if( a < c )
{
min = a;
}
}
else
{
if( b < c )
{
min = b;
}
}

return min;
}

/*
red- recursive edit distance

*/
int red(char *x, char *y)
{
int d,e,f;

/* Base cases */

if(*x==0)return strlen(y);
if(*y== 0)return strlen(x);

/* Recurse */

if(*x==*y)
d=red(x+1,y+1);
else
d=RC+red(x+1,y+1); /*replace*/
e=IC+red(x,y+1); /*insert*/
f=DC+red(x+1,y); /*delete*/

return minimum(d,e,f);
}

int main()
{
char source[]="kitten";
char target[]="sitting";

printf("Minimum cost to convert %s into %s is %d\n",source,target,red(source,target));

return 0;
}
[/sourcecode]

The DP solution:

Here is the idoene link for the DP code. Play with it if you find the DP code difficult to understand !!

[sourcecode language="cpp"]

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define IC 1 /*cost to insert*/
#define RC 1 /*cost to replace*/
#define DC 1 /*cost to delete*/

int minimum(int a, int b, int c)
{
int min = c;

if( a < b )
{
if( a < c )
{
min = a;
}
}
else
{
if( b < c )
{
min = b;
}
}

return min;
}

int edit_distance(char* s1, char* s2)
{
int d;
int m = strlen(s1);
int n = strlen(s2);
int dp[m+1][n+1];
for (int i = 0; i <= m; i++) {
dp[i][0] = i;
}
for (int j = 0; j <= n; j++) {
dp[0][j] = j;
}

for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (s1[i-1] == s2[j-1])
d = 0;
else
d = RC;
dp[i][j] = minimum(dp[i-1][j-1] + d, /*replace*/
dp[i-1][j]+IC, /*insert*/
dp[i][j-1]+DC); /*delete*/
}
}

return dp[m][n];
}

int main()
{
char source[]="kitten";
char target[]="sitting";

printf("Minimum cost to convert %s into %s is %d\n",source,target,edit_distance(source,target));

return 0;
}

[/sourcecode]

Try understanding how the DP matrix will look like. For the above wiki example, here is the DP matrix:




























































































kitten
0123456
s1123456
i2212345
t3321234
t4432123
i5543223
n6654332
g7765443

You can also try different inputs to see what the result could be here. Both time and space complexity of DP solution is O(nm). The sequence of operations performed can also be printed but for that we need to use an additional O(mn) space which will save the operation performed along the way and the sequence can be found recursively moving backwards. See the Instructor’s Manual by Thomas H. Cormen, Clara Lee and Erica Lin to accompany the cormen's text if you find any difficulty. Note that the space requirement can be improved to O(n), as in each iteration only requires element from the current and previous row but in this case retracing the path to find the operations used and their order is not possible. Also note that there may be more than one of these paths and the above solution chooses one of them.

Modifications:

  1. Substring Matching

  2. LCS - make the cost of replacement greater than that of an insertion plus a deletion.

  3. Maximum Monotone Subsequence


For an explaination on what modifications are needeed in each section refer Programming Challenges by Steven Skiena( no 3 here).



References: 

Here are a few materials that discuss the algo/implementation:



Saturday, March 3, 2012

Internship at IIT Bombay

NOTICE

You can still apply for an internship program at IIT Bombay this summer. I have an experience of it and I can assure you that its a really good environment. You will get to learn a lot. Plus, Bombay is such an excellent place to visit :) I received an e-mail from them today. Here is what it contained:
Dear Students,

We are pleased to present an opportunity for direct placement into SummerInternship 2012, Under the guidance of Prof. D.B Phatak, IIT Bombay
As you know, last year only 60+ students were selected from nearly 700 applicants. After seeing the quality work and enthusiams, this time we are extending our intake.We are requesting all of you to use your software skills to contribute to an ambitious initiative http://ekalavya.it.iitb.ac.in/ekalavyaHome.do to provide quality education to underprivileged students. This is the great chance for you, to get good exposure to programming challenges and enhance your skills.
Even if you are not interested or eligible in joining the summer internship,
Please forward this mail to your friends, so they can make the most of thisopportunity..
Visit http://ekalavya.it.iitb.ac.in/summerintern2012 Summer Internship 2012 - Registration Open and register.

Thanks and Regards,
Summer Internship Team

If you are in BE/B-tech third year and want to get into an internship program, I think you should go for it.It will also be open for second year students but third year people are generally preferred. Leave a comment if you have any clarifications !!!

Wednesday, February 29, 2012

Our Google has CHANGED !!! But is it Evil ???

Have you seen something like this on the google home page recently?? If you have, congrats you are aware of the issue and i would love to have your views. If not, let me inform you that Google is going to make a few changes today(march 1, 2012). But does it matter ?? Should you bother ?? Probably, that is what I want to discuss with you - whether it matters or not ?? Let me first mention what is going to change after all. If you are aware of the policy changes, you may skip the next section.

Whats the fuss about ??

Have you ever looked at your google dashboard ?? I have got a picture for you from mine.  Look at the picture below (taken on FEB 29,2012) and try following the arrows.



Did you notice that every product from Google has a privacy policy associated with it. So what ? Everything on the web has !! Wait a minute though !! From now onwards , there is going to be a change here. Yes a change in the google's privacy policies. And I am quite happy with the fact that Google has been trying its best to notify everyone of the same unlike facebook  where the policies change as frequently as rumours within your group of friends !! Getting back to the point, look at the next picture now, taken on MARCH 1,2012 .



By now you might have guessed that Google is going to get rid of all these policies (more than 70 of them) and replace them with one super-duper one !! Looks great. Isnt it ? Some have embraced the change, some have deemed it to complicating , some have also termed it  dangerous (in terms of privacy/security) because google is always watching you but every one in the tech world is definitely concerned. Here is how Google described it (slightly edited to make it short) -
We have more than 70 privacy documents covering all of our different products. This approach is somewhat complicated. It’s also at odds with our efforts to integrate our different products more closely. So we’re rolling out a new main privacy policy that covers the majority of our products and explains what information we collect, and how we use it, in a much more readable way.

In short, the big G wants to  treat you as a single user across all its products, aiming at  a simpler and  more intuitive Google experience. But the point is how does it affect us ? I will divide it into two. Lets first see how it can be advantageous:

Its for the GOOD

For quite some time , Google has been advertising the one policy, one google experience funda. and if it is to be believed, this will

  1. Make it easy to work across Google,

  2. Tailor your search results – based on the interests you’ve expressed in Google+, Gmail, Calender, Alarm ,YouTube etc

  3. Make it easy to share and collaborate,

  4. NOT change the fact that Google values your privacy and

  5. Make it easier to understand how it uses your data because you have to read only one page to understand how google collects and uses the information about you.


Still confused ? Do you have a  question ? If yes, turn to the google's FAQ  section on privacy . Lets now get a little further and interpret this. When you do a Google search your results will be personalized for you. Suppose one visits a particular web site often, or if his friends have shared a link, those are personal signals that can be used to reward a listing and cause it to rank better(to understand the ranking better visit my previous post). Sounds kind of good, right ?? Then why all this blah-blah ?? Looka at the next section now.

Why NOT a welcome change ??

Recently, Larry Page( Google's CEO )has been receiving letters saying that the company's latest privacy policy updates, are "troubling for a number of reasons" and "invade consumer privacy." Add to it the reports that Google's Search Plus Your World integrates Google Plus, the company's social network, into its search results, seemingly at the expense of its rivals in social search, Facebook and Twitter. This appears to go against the company's founding principles (Dont be Evil-see no 6 here). Suppose your friend shared a picture of his "kitchen" on Google+ (or Google Picasa), next time when you search Google for “kitchens” you might see the picture of your friend's kitchen. Is that what we expect Google search to do for us ? Similarly, if someone wrote a Google+ post about a great car repair place — and only shared that with friends like you — when you search for “car repair,” you might see that post showing up in the top results instead of the best one. And the worst part - if your friend tries to spam you, suppose by sharing something many times , you could see the effect in search results. Is that justified ? Or is the big G biased to suit itself, probably to promote its social networking site(Google+) ? 

Lets now think the other way. People these days leave a lot of information on the social networking sites. These too are pieces of information and is that not exactly what Google is supposed to do ? Process information everywhere and find the most valuable ones . Now everywhere means the social networking sites too. But then Facebook and twitter which share a good share of social networking dont allow Google to extract your info you provided them or from that matter whatever you scribble there . In that case what does Google do ? Use only Google+ to find that kind of  information. Now that sounds interesting, Right?? If yes, thats what my aim was - to make you think if this is for good or bad ? 

Whats my take - Evil or not Evil ?

Let me first tell you that I am a big fan of Google products specially Gtalk (I think Gtalk is just too smooth and error free too. Isnt it ?). I agree that Facebook and Twitter not being apat of Google's search for social info (only Google + is) is a big setback but how is Google to be blamed for that ?? And when Google planned to include this sort of information into your web search results, it did ask twitter to let them access their info about people but it was Twitter that disagreed. I am not very sure about Facebook though. You would now say that Google will know too much about me implemeting this streamlining of all data. To that, Iwill just answer that Google always had a lot of info about you. Its been that way since day one. If you just search a lot on Google, Google knows a good deal about what interests you. So what!  If you use any Internet service or Web site a lot they know a lot about you. Add to it that Google lets you manage this info through its dashboard as well (visit this Youtube link to know about Google Dashboard). If you dont like the fact that Google tracks your web search historygo to your Google Web History page and hit the pause button, and then choose “Remove all Web history.” and you’re done with it. Rather,  if you are not signed in , it is quite probable that you wont get the information from Google+ appearing at the top of your search results. Finally to the people who clam that Google knows more about one's wife than he himself does (a very popular quote, have seen this a lot on web during my research for this post:D) , once you are on web, there is always a chance that you can be tracked. You have to trust someone, I choose to trust Google. Do you ?

[polldaddy poll=5992499]

Of all the articles I read , this one one stood out. And you can probably find that influence in my post too. I would suggest you to go through the article. Its really good !!

Tuesday, February 28, 2012

Inside Google - An introduction !!!

Ever googled "google" ?? I have not :D Trust me, the final semester at college (at least in our part of the world) leaves you with so much of time that you do all crazy stuff . With no work , an awesome cricket match and a lot of time I did just that and  actually discovered quite a lot.

Basics :

Do you know where the term "GOOGLE" came from ?? Its a misspelling of the word "googol" meaning the number 1 followed by hundred zeroes. It symbolises the fact that  Google wanted to provide large quantities of information for people. Sergey Brin and Larry Page were the founders. The mission  was "to organize the world's information and make it universally accessible and useful", the commpany's unofficial slogan is "Don't be evil". Larry himself defines an idle search engine as one that would "understand exactly what you mean and give back exactly what you want". A 10-point philosophy  defines google and the founders say-
We first wrote these “10 things” several years ago. From time to time we revisit this list to see if it still holds true. We hope it does–and you can hold us to that.

How The Google Search Operates :

Search is how Google began, and it’s still the heart of it. Here is how the google search operates:

  1. When you type your query and hit "enter" , you dont search the entire web but the an index of it (yes, very similar to the index at the back of a text). This is the google's index for the web, not to mention, it is consistently updated.

  2. The indices are searched with help of spiders . The spider runs through millions of  pages (technically called "crawling")  to find ones that  contain the keywords contained in the query you typed.

  3. Next , it follow the link on those pages and fetches the pages they point to. You have more pages.

  4. step (3) iterates until  until a big (Its really big !!!)  chunk of the web has been traversed.

  5. The final question -  How does Google then decide which of them are relevant ?? Based on:

    • How many times does the page contain the keywords in the query ?

    • Do the words appear in the title or in URL?

    • does the page include synonyms of the keywords ?

    • Is this page from a quality website ? ,

    • the popularity of the page,

    • the position and size of the search terms within the page

    •  and the proximity of the search terms to one another on the page

    • And much more !!!



  6. The algorithm then combines all the results to compute the score obtained by each page (the  pagerank) and sends you back your search results.


Imagine all this happening within half a second between you typing your query and seeing the result on the Google home page !!! Thats Goolge for you :) If you want to know more , turn to the Google-guide or  see   how stuff works.

The Road Ahead:

The big G believes that search can always get better and faster at helping you find what you want, when you want it, where you want it. And that led to the evolution of "apps" (the applications-gmail, googleDocs, Calender etc).



Google-images: As google got better, people expected more. In due course of time, Google realized that  people want nothing but the best possible information available - be it a picture,a book or for that matter ,information in any form , not just web pages. The result was Google-images.

 Google-news: Lets take an example.When 9/11 happened , people searched google for "Attack at WTC".Unfortunately,  the results had nothing relevant with the  events happened . The reason- the google index was crawled one month ago and at that time there so no such info on web. Google news emerged as a result of this sort of needs of the users.

Universal Search: Gradually, web became  richer with more images,more videos , and all sorts of contents of different kinds. Now users expected google to find anything that existed on web. They didn’t care if it was text or webpage or news . They wanted all in one place and google came up with the Universal search.

You can find all the Google products here. To see what you have been doing at google recently and how google has stored all of them you may also like to visit the dashboard. You can manage (or edit) all your info here too.  Google has always been looking at innovation, always wanting to know what the users want. To get the latest features, tips and tricks from Google , keep connected to this.

What Recently???

Recently, Google has been at the receiving end of a lot of controversies - regarding

  1. its personalised search and

  2. new privacy policy.


I have  already covered the first , to an extent, in one my previous posts.  Regarding the second , If the reports are to be believed , Google is going to combine its 70 different product-specific privacy policies and terms of service into one super-duper privacy policy on March 1, 2012 . It will be interesting to see what the reactions of users are !! And  I will try to cover them in my next post !! Stay connected.

Any corrections are welcome !!

Sunday, February 26, 2012

HTML 5 to the rescue !!

In my last post in the tech-talks category , I left you with a question -  Will the technology in near future be radically different ?? If yes, what will be its new look ?? Here I am, to discuss one aspect of it - The HTML 5 vs Adobe flash saga. There has a been a long rivalry between the two .The most popular opinion being - HTML 5 is on the way to killing adobe flash . At least for mobile applications, it has .Two years ago if I asked you to imagine web without flash , the general reaction would be - What crap!!  But one man did . Steve Jobs foresaw this very early . In april 2010 , he said -
Flash was created during the PC era for PCs and mice. Flash is a successful business for Adobe, and we can understand why they want to push it beyond PCs. But the mobile era is about low power devices, touch interfaces and open web standards all areas where Flash falls short. Flash is no longer necessary to watch video or consume any kind of web content."

He also described Flash's performance and security as sub-standard and refused to allow Flash on the iOS due to the many bugs and crashes it experiences. There is no Adobe Flash Player for iOS devices (iPhone, iPad and iPod Touch). Being in  this part of the world it is not that evident but The iPhone accounts for more than 60% of global smartphone web traffic and the iPod touch makes up more than 95% of "mobile Internet device" traffic. This hurt Adobe's ability to market Flash as a ubiquitous mobile platform. Lately adobe flash seems to be completely  out of flavour with the mobile version of Internet Explorer 8 for Windows Phone not supporting Flash. The IE9 web browser on Microsoft Windows Phone 7.5 ('Mango') does not support Flash either.

The SWF crash torture:

Some people hate flash. Not because it’s slow or drains battery life or makes the computer hot. Mostly these go unnoticed . Its  because it constantly crashes and it’s not getting any better.  For long my web browser of choice was Google Chrome and if you happen to be on the same boat , these pictures will seem very familiar :


I think I don’t need to explain why I dont like  Chrome anymore . It pretty  much forces  to use Flash since it’s built in to the browser. But Google seems to have realised that  :) for google has bet big on HTML 5 too. YouTube has offered users the option to opt into  HTML5 beta for over a year now, which allows you to dispense with Flash when watching videos on the website.Unfortunately, YouTube still forces you to watch videos using its Flash-based player when it has ads in it, so you’ll often end up doing so despite being a member of the HTML5 beta, forcing you to resort to other, browser-based methods to get access to the HTML5 version of the video. However, the fact that YouTube is silently working on improving its HTML5 player signals good things for the technology.


Flash is Dead, Long live HTML 5


Adobe's love affair with its Flash format has finally come to an end. On November 9, 2011, Adobe announced that it will no longer develop Flash for Mobile Platforms and is planning on developing new products with more open technologies and standards like HTML5, JavaScript and CSS3. Adobe’s VP and general manager of interactive development, wrote-




Our future work with Flash on mobile devices will be focused on enabling Flash developers to package native apps with Adobe AIR for all the major app stores. We will no longer adapt Flash Player for mobile devices to new browser, OS version or device configurations. Some of our source code licensees may opt to continue working on and releasing their own implementations. We will continue to support the current Android and PlayBook configurations with critical bug fixes and security updates.



In simpler terms , Adobe is Stopping development on Flash Player for browsers on mobile. To add to that , In February 2012 Adobe announced: For Flash Player releases after 11.2, the Flash Player browser plugin for Linux will only be available via the "Pepper" API as part of the Google Chrome browser distribution and will no longer be available as a direct download from Adobe. Adobe will continue to provide security updates to non-Pepper distributions of Flash Player 11.2 on Linux for five years from its release. It seems that getting by without Flash is becoming easier.


The flavour of the season - HTML5:


Many have embraced it, a few have discarded it  as too far in the future, and some have abandoned a misused friend  in favor of an old flame in preparation. Whatever side of the debate you’re on, you’ve most likely heard all the blogging chatter surrounding the “new hotness” that is HTML5. It’s everywhere, it’s coming, and you want to know everything you can before it’s old news.


HTML5 is well on its way to becoming more than just a markup language for web pages. Rather, it will be a development platform in its own right. In practical terms, this means support for HTML5, along with CSS3 and JavaScript, as a way to create real applications, not just webpages. HTML5 still has a long way to go before it becomes a final standard but many of its advanced features are being implemented now. Latest versions of browsers such as Internet Explorer, Mozilla Firefox, Opera, Google Chrome, and Apple Safari have already implement HTML5 to some extent. It will take some time for HTML to completely take over . Even though HTML5 video is becoming more commonplace, I don’t think I could do without having Flash installed on my machine just yet. But  yes I can imagine it coming . For now , it may interest you to look at these:




  1. HTML5websites.net showcases websites from all over the world made with the HTML5 markup laungauge.

  2. 45 examples of ebsites designed with HTML5

  3. Top 10 best HTML5 websites of 2012


Or if you belong to a developer community and want to know the nitty-gritty details , you may find some helpful content here.

The Desktop context:

If analysts are to be believed, Adobe's move to ditch Flash Player for mobile browsers was smart. To me it occurs that Keeping Flash Player alive on the desktop will work for a while, but eventually it too will be supplanted by HTML5, With the large mobile and tablet market free of the already diminished influence of Flash, and with sites like YouTube and Vimeo going the Flash-free route, it’s a good bet that HTML5 will overtake the resource-heavy plugin on the desktop eventually, despite its current dominance. Microsoft, for one, has already said it will block the Flash Player plug-in from being installed on the touch edition of Internet Explorer 10 (IE10) within next year's Windows 8.What do you think, though? Could you live without Flash?






[polldaddy poll=5980642]

References: Here are a few things that helped me gain insight into the matter:

  1. Adobe Flash - wikipedia ,

  2. Comparison of HTML 5 and Flash - wikipedia

  3. Youtube's HTML 5 player steadily gaining ground on Flash

  4. Surviving the world without adobe flash

  5. Networking blogs by Steven J. Vaughan-Nichols


Any corrections are welcome !!

Thursday, February 23, 2012

Journey of a pointer from NULL to FREE

Why C ???

In this dynamic IT world new languages come every day and get obsolete, so there must be     something in  C which has remained there for 4 decades and more and even today there   is hardly any language which can match its strength.Though C is simple it is one of the most powerful languages ever created. Wiki puts it this way:
 C is the most commonly used programming language for writing operating systems. Unix was the first operating system written in C. Later Microsoft Windows, Mac OS X, and GNU/Linux were all written in C. Not only is C the language of operating systems, it is the precursor and inspiration for almost all of the most popular high-level languages available today. In fact, Perl, PHP, and Python are all written in C .

There must be a reason. Indeed there is !!!  C is the most elegant one. Not only that,Once you learn C, making the jump to Java or C# (and others too) is fairly easy, because a lot of the syntax is common.

But then , why POINTERS in C ???

Acoording to Yashwant kanetkar  :
A C programmer without knowledge of pointers is like a fish which doesn't know how to swim. He needs command over pointers to be able to exploit the immense potential of C. Pointers are all about power and punch. But then its not easy being comfortable with the usage of pointers. No matter how much time you have spent with it, you will always find some application of it that would leave you guessing !!!

 No Pointers => No data structures .You need to have a fair bit of command on pointers to get along with the implementation of linked lists and trees . So pointers are immensely important and to be called a good C programmer one needs to master them. At least to get through the recruiting process of good technical firms (for software developers) one needs the knowledge of pointers.  There is a dark side to it as well , pointers are  error prone. So  be very sure you need it when you actually want to use it in an application .

A piece of Advice:

Understanding pointers in C is not a skill, it's an aptitude. So be sure you try to understand them , not learn them. There is no end to the questions that can be framed on pointers, there is no end to the situations you will get trapped into when you try debugging some of your codes that involve pointers. Trust me these are very tricky. Dont try to remember that so and so happens in xyz situation and those kind of stuff. Some common situations you land yourself into while you battle with the pointers  in C  are :



Last but certainly not the least, try compiling the codes you come across in your own compiler or for this matter you may also find ideone useful, I certainly do :) Play with them, Try debugging them . This is the best way to learn!!!

The biggest Quesstion - How  ???

If you are  decent with the understanding of C and struggling with pointers , this blog is specially designed for you. There is a huge volume of material available on internet, then why this one ? The problem is- most of them are simply BADLY EXPLAINED ONES !!! . I am by no means  the best person to explain the nuts and bolts of pointers , but I  have a read a lot of them and therefore I can point you to some of the best ones available .  Before you attack pointers if you want to brush up  C quickly, you may  love to go through this. But then it is not mandatory to do that. Here is a list of things you would like to own if you have made up your mind to master pointers today:

  1. Pointers and memory  by Nick Parlante (from stanford): This document explains how pointers and memory work and how to use them—from the basic concepts through all the major programming techniques. For each topic there is a combination of discussion, sample C code, and drawings. Go through it word-by-word. Get into the habit of drawing memory diagrams as explained here. I bet it will help you a lot.

  2. The C Programing Language by Brain W Kernighan and Dennis M Ritchie (K & R). It is undoubtedly the best text available on C and one of the thinnest too :D .Grab a copy of it from  amazon.com or may be flipkart (preferable if you stay in India). If you dont want to buy a book , go through the reviews . Whether you buy it or not, you will be impressed for sure. And try doing the exercises as well.

  3. K & R is not for  beginners . So , if you are one , you may also go through  Understanding Pointers in C  by Yashwant Kanetkar. This book covers everything that has anything to do with pointers in a simple to understand way. The topics covered include: 

    • Pointers and Arrays

    • Pointers and Structures

    • Pointers and Dynamic Memory Allocation

    • Pointers to Functions

    • Pointers and Variable Argument Lists

    • Practical use of Pointers

    • Pointers and Doubly linked Lists

    • Pointers and Circular Lists

    • Pointers and Binary Trees

    • Pointers and Threaded Binary Trees



  4. Once you are done with these , you will really feel comfortable implementing your data structures viz.. linked list or binary trees etc.


In reference to the point no (4) above , You may first like to go through these :


All three references above are from Nick Parlante himself and once you are done with "Pointers and Memory" (numbered (1) above) , these are excellent materials for practice .

Some Good Habits :

  1. Initialize pointers when declared.Never leave pointer variables uninitialized - things wouldn't be too bad if uninitialized pointers always contained random values - the vast majority of random values are illegal pointer values and will cause the program to crash as soon as they are used. The problem is that uninitialized variables tend to take on the value of other, previously used pointer variables. These problems are very difficult to debug.If you don't know what else to initialize a pointer to, initialize it to zero. Zero is guaranteed to be an illegal address.

  2. Zero pointers out after you use them.Similarly, always zero a pointer variable once the pointer is no longer valid. This is particularly the case when you return a block of memory to the heap using delete; always zero the pointer after returning heap memory.

  3. Allocate memory from the heap and return it to the heap at the same "level" to avoid memory leaks.Always try to return a memory block to the heap at the same level of abstraction as you allocated it. This generally means trying to delete the memory at the same level of function calls.

  4. Catch an exception to delete memory when necessary.Don't forget that an exception can occur at almost any time. If you intend to catch the exception and continue operating (as opposed to letting the program crash), make sure that you catch the exception and return any memory blocks to the heap before the pointers that point to them go out of scope and the memory is lost.

  5. Make sure that the types match exactly.Always make sure that the types of pointers match the required type. Don't recast a pointer without some specific reason. Consider the following:
    void fn(int* p);
    void myFunc()
    {
    char c = 'a';
    char* pC = &c;
    fn((int*)pC);
    }

    The above function compiles without complaint since the character pointer pC has been recast to an int* to match the declaration of fn(int*); however, this program will almost surely not work. The function fn() is expecting a pointer to a full 32-bit integer and not some rinky-dink 8 bit char. These types of problems are very difficult to sort out.


Congratulations !!! You are now set to conquer the world :D

Comments/Suggestion, if any : Please feel free to offer any general comments/suggestions/advice you may have about material or articles here. Llinks to websites that you feel would be a good reference for others to visit would really help .  ******************************************************************************************************************************************************************************************