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 .  ******************************************************************************************************************************************************************************************

Wednesday, February 22, 2012

The t-20 way !!!

When England adopted the 3-captain theory recently , I was completely unimpressed and thought it would just create a confusion  .



What if the T-20 captain drops the ODI captain from his team  with  the T-20 captain  still being part of the ODI side ?? What if his performance drops in ODIs , would the captain still persist with him because he looks a talented player ?? I agree the players are true professionals , still they are  human !! Wont they secretly wish that the colleague be dropped from his side ?? Probably NOT  but what if the ODI captain is really a professional and drops him ?? what would the speculations be ?? Would it affect the selection ?? The questions are many but none can be answered because its all situational !! There is no clear-cut answer to these questions .

Whatever be the situation in the england-cricket circuit , Team India is fortunate to have such a talismanic leader at the helm-Dhoni ,the perfect one !! His feets need no mention . He started with T-20 world-cup , took the test-team to the numero-uno position and won the ODI world cup 2011 too . Add to that IPLs and champions trophy !!! Its a really big list . As a player too his stature is commendable . There was a time when the very idea of an Indian cricketer rivalling Sachin Tendulkar in the popularity stakes bordered on the preposterous. But the advent of Mahendra Singh Dhoni and his meteoric rise through the ranks did just that, with a new generation transfixed by a small-town boy whose personality and background couldn't have been more different from that of Tendulkar.

But then , the current situation is alarming !!! Cricket is a team sport and no player can be valued more than the spirit of the game itself . With 8  continous test  losses overseas that too  most of them being humiliating ones and more losses than wins in T20 internationals , something must have gone wrong for sure . Including tests and T20 in the sam sentence would bother a lot of people but these are two formats of the game and both are important , a loss is a loss !!! I dont understand BCCI and selectors giving so much of importance to IPL , far lesser to T-20 internationals !! A T-20 loss seems to bother no one , I dont find a reason Yusuf Pathan not being sent for the 2 matches played in australia ,  is he not fit to play this format or is it because t-20s just dont matter ?? If they dont why have them scheduled at all ??? The only interpretation i can found is that t-20s are far less important compared to tests and ODIs .

But you see the same question again - "t-20 losses  just dont matter" .  Actually it does , it provides a momentum , a winning mindset . Had it not been very encouraging if India had defeated Australia in both the t-20s convincingly ?? Its high tome we had a different t-20 captain which will mean , there will be someone who will find these important . Not that there is no suitable person available . Kohli , Raina or even Gambhir , I think , are good .

[gallery]

The attitude of kohli is just that required . Also he can be groomed this way to be the next captain !!! The case of Gambhir is interesting . He is an experienced campaigner and would definitely be a safe choice but then do we see him captaining the ODI/test side after dhoni is relieved with the same ?? Probably not !!! Raina , I think has some technical adjustments to make and then prove that he can play the short-pitch stuff too .

[polldaddy poll=5968448]

I have included Yuvi too in the polls , because he could be a popular option too , but then  he is out of the side now as a result of some major  health problems . I just wish he is back on the cricket field soon . We miss watching him in blue and hitting some monstrous sixes :D .

The next t-20 world cup is approaching fast . But are we desperate enough to win it ?? Are we planning ??? Dhoni has won 2 world-cups . Others may probably be more desperate to win one . For someone other than Dhoni , it will definitely matter a little more . As far as ODIs are concerned , Dhoni is going great and there is not much choice for the test captaincy .  Last but not the least , Dhoni is also a human being and you can not burden with him all the responsibility  , he needs some time for himself as well !!!

Sunday, February 19, 2012

The golden age of TECHNOLOGY !!!

In an article in 2006, tech columnist John C Dvorak asked: "How many people realise that we're living in a golden age, the Golden Age of the Internet? It won't last; golden ages never do. Some of it will remain, but there's evidence that much of it is headed for the trash heap of history." That's an overstatement of course. All golden ages (if that is indeed what we are living through) have their dark sides. In the internet's case, that dark side means spam, phishing scams, viruses , and a lot more.

It has been quite sometime that I kept looking for the best resources to follow , in terms of the daily news . To start with , I subscribed for a newspaper "The times of India " - the Ranchi edition . Bored of reading about Jharkhand politics (a fair share of the first page contents ) I went for "Business line" next (by the  Hindu !! ) , but then it had too much of business news :P , Next in line was The google news , but finally i think i  have settled with the google-chrome add on for "times of India" . Trust me its a good one . Just open your google chrome (note that an an updated version of chrome might be better) , go to chrome web store -> news and weather -> news reporting . Now try finding the times of india add-on and add it to chrome . The next time you open your google chrome go to apps ("apps" and "most visited appear at the bottom ") and launch TOI . You will find a smooth interface to all kinds of news . Hope you like it too , I definately do :) .

Coming back to the tech world lets first look at something positive, Windows-8 seems to be grabbing a lot of attention . Microsoft looks to have added quite a bit to it. Here is a list of  changes we will see :

  1. It will replace the Start Menu with a Start Screen - with tiles that contain shortcuts to applications - similar to the Metro interface seen on its Windows Phone 7 OS.

  2. To allow for better security, Windows 8 utilizes a new system that incorporates pictures and gestures in user authentication. It's a simple concept: Users will first need to select an image on which to perform a gesture. The gestures could be tapping on something in the picture, encircling something, or drawing a line between two points.
    A "password" would then comprise any combination of these three.

  3. With Windows 8, you will even be able to take the entire operating system with you. Enterprise versions of the OS will be capable of running off a flash drive or portable harddrive .

  4. A "refresh and reset" option  resets your installation to its initial state. It deletes all your personal data and software, leaving a fresh Windows 8 computer that you can even hand over to someone else .

  5. Secure Boot, which will ensure that the system being booted has not been tampered by malware. Another anti-malware feature in Windows 8 is a technology it borrows from Internet Explorer (IE), called SmartScreen. SmartScreen checks URLs entered in the browser against a database of malware links, and in IE9 this feature was extended to downloaded files.

  6. Conflicts while copying are also managed better. If while copying from one folder to another Windows detects multiple conflicting files, it can show you a detailed list of files in both the folders and the differences between them, along with the option to skip files that are exactly the same on both sides.

  7. Lastly , it is trying to redesign its iconic windows logo  . The new windows logo will not be much different though . It has a slightly angled blue block with a thin white cross in the middle, making it look like a window instead of the 4-colour wavy flag in the past . This is the new logo , below is a history of changes in its logo .


                              

For full coverage , you can visit this page . This is where i learnt some of  these .

Unfortunately , Google  seems to get into news for all the wrong reasons these days . For long  it has drawn scrutiny and pressure from consumer advocates for the way it handles personal information. To add to this there has been a rift between twitter and goolge  with twitter claiming that google is trying to use data from google+ and twitter to display in its search results and i completely agree that its not a good user experience . I have tried using g+ these days ( just to find how google expected people to move towards it  ), only to find a number of people in my circles in g+ added to my Gtalk list  , which i found really bad !!! Recently , Apple  has  claimed that "Google bypassed privacy settings of  safari ,the most widely used browser on mobile devices and the default browser on iPhones and Mac laptops .

We are only in the second month of 2012 , but there has already been reports saying that 2012 could turn out to be the  Year of war against cyber crime . Check the reports yourself . With all these i sometimes wonder  -

 Will the technology in near future be radically


      different ???  What will be its new look ???


To end with , I cant stop myself from mentioning this . It may sound like another Rajinikanth joke, but if reports are to be believed , a new website dedicated to the superstar runs 'without an internet connection !!! You can find the "times of india" report here .You may classify it as technology  or a piece of comedy , but I tried it , probably because i love rajnikanth jokes too  , and trust me it worked :D. Try it yourself . I bet you will at least have something to make fun of :P if not more .

Friday, February 10, 2012

Getting Started With uvaonlinejudge ...

What is uva online judge after all ???

According to wikipedia , UVa Online Judge is an online automated judge for programming problems . The system can compile and execute codes and test them with pre-constructed data. Submitted code may be run with restrictions, including time limit, memory limit, security restriction and so on. The output of the code will be captured by the system, and compared with the standard output. It will then inform you whether your solutions are correct (AC) , or faulty and in the latter case it will also tell you what the problem was viz..

  • Your code could not be compiled on their compiler ,

  • Your code did not produce the correct output for all the test cases they tried (WA) ,

  • Presentation error - you did not display the output the way they expect you to  etc.....


The registration is open to all users (and free of cost too :D).  A user may submit a solution in C, C++, Java or Pascal.  You just have to get yourself registered at the site .

Solving a problem on the UVa Online Judge requires the following:

  • Read and understand the problem statement .

  • Devise an algorithm (may vary from a very simple one to an extremely tougher one) to solve the problem .

  • Implement the algorithm in C, C++, Pascal or Java .

  • Finally, if you are convinced of its correctness, upload your code to have it judged.


The judging is automated (they use benchmark input and output files), so you can typically expect a response within a few seconds. After all the theory above (we have had enough of it :P) , lets try and solve a problem at the uva site.

Getting started : A step-by-step approach

Lets get started with an easy question  :) . I have selected the  problem at the uva  called Back to High School Physics . It is indeed an easy problem . Go through the question , use sample input and sample output section to see what they really need . Once you get a feeling of what to do , try finding out the formula (the so called "algorithm" for this problem) . Think hard if you dont get it  ,

  • visit this link .

  • click on volume 100 (since it is question no 10071 on the uva site)

  • Scroll down and you will get a hint to the problem .


Alternatively ,  search google for  10071 - Back to High School Physics . Click on a link from the algorithmist's site . You will reach here . You could find some clues here too . But please try yourself before you go onto look at the hints using one of the two methods  because thats the whole motive behind starting with uva .  By now you are ready to dive into your compiler and code ,so do it !!! . You may also use ideone .  Its a really good place to try different input/ outputs and check if your code is error-free . Let me post the solution for this question to show you a sample solution :

[sourcecode language="cpp"]

#include<stdio.h>
int main()
{

long int v,t,s;

while(scanf("%ld%ld",&v,&t)==2){

s=v*t*2;

printf("%d\n",s);

}
return 0;
}
[/sourcecode]

Log in to the uva website  . Go to Quick submit on the left . Enter question number on uva site (10007 here) , choose a language (click on C for above sample code) , copy-paste your code here (you may browse it as well :) ) and submit your code Congratulations !!!! you have now submitted a solution at the uva site (if you get AC- accepted) . You can check the status of your submission by selecting the “My Submissions” link on the left side of the page. The “Verdict” heading will tell you if it was solved or if there was a problem (e.g. wrong answer, ran too long, crashed, too much memory was used, compile error, etc).

Now go ahead and solve some more problems  !!!

Next Problem to Solve :

As there are large number of problems to be solved, you have to select problems. The best way according to me is  Felix Halim’s website. Just punch in your username and see the miracle. Bookmark the page, at least that’s what I did :D .

Use Felix Halim for figuring out what problem will be easiest to find:


image


Or you can also get Topic wise problems:


image


Another word of advice, the solutions for UVA are available abundantly on the net. Please do not copy, as this is not a competition!





  • First try to solve a problem by your self.


  • If you keep on getting WA’s, Try UVA Toolkit to check for critical input.


  • If you still get WA’s, try reading on UVA forum and you might get critical test cases there!


  • Still a WA then read a solution, but definitely write your own code!


AC’s are heavenly, work for them! Have fun…Enjoy coding!!!


If you use google-chrome :


Sometimes , The site wont open and it will  show a redirect loop. It is solved by removing the cookie onlinejudge.org. It can be removed in the following way. Open options->under the hood:


image


Click on “content settings”, and in “cookies” sections click on “all cookies and site data”.


image
now search for onlinejudge.org cookie and delete it..Tada problem solved!( P.S. the screenshots are from this page ).

Tuesday, February 7, 2012

LCS and LIS .....

LONGEST COMMON SUBSEQUENCE

LCS stands for Longest common  subsequence . It is a classic computer science problem, the basis of file comparison programs such as diff, and has applications in bioinformatics. If you are studying LCS for the first time , I would recommend   you to read  it from CLRS- Introduction to Algorithms . Charles Liesersen (one of the authors of the book) himself explains it here  . I must confess he explains it pretty well in this video . You may also  visit the corresponding wiki article  Its a pretty long article but they have mentioned everything  very neatly .

LCS Problem Statement: Given two sequences, find the length of longest subsequence present in both of them. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, “abc”, “abg”, “bdf”, “aeg”, ‘”acefg”, .. etc are subsequences of “abcdefg”. So a string of length n has 2^n different possible subsequences.

Examples:
LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of length 3.
LCS for input Sequences “AGGTAB” and “GXTXAYB” is “GTAB” of length 4.

Still not clear with the problem formulation / algo ?? look at the animations here.

Here  is a code of mine that finds the LCS of two strings given as input .

Recursive code:

[sourcecode language="cpp"]

int max(int a,int b)
{
if(a<b)return b;
return a;
}
int recursive_lcs_length(char * x, char * y)
{
if (*x == '\0' || *y == '\0') return 0;
else if (*x == *y) return 1 + recursive_lcs_length(x+1, y+1);
else return max(recursive_lcs_length(x+1,y), recursive_lcs_length(x,y+1));
}
[/sourcecode]

Recursive code takes O(2^n) time in the worst case- the two strings have no matching characters, so the last line is always executed. Its very inefficient. Lets now see the DP code.

Dynamic Programming Code (Bottom-up):

[sourcecode language="cpp"]
#include <stdio.h>
#include <string.h>
#define MAX 100
char X[MAX],Y[MAX];
int i,j,m,n,c[MAX][MAX],b[MAX][MAX];

int LCSlength()

{
m=strlen(X);
n=strlen(Y);
for (i=1;i<=m;i++) c[i][0]=0;
for (j=0;j<=n;j++) c[0][j]=0;
for (i=1;i<=m;i++)
for (j=1;j<=n;j++) {
if (X[i-1]==Y[j-1]) {
c[i][j]=c[i-1][j-1]+1;
b[i][j]=1;
}
else if (c[i-1][j]>=c[i][j-1]) {
c[i][j]=c[i-1][j];
b[i][j]=2;
}
else {
c[i][j]=c[i][j-1];
b[i][j]=3;
}
}
return c[m][n];
}

void printLCS(int i,int j)

{
if (i==0 || j==0) return;
if (b[i][j]==1) {
printLCS(i-1,j-1);
printf("%c",X[i-1]);

}
else if (b[i][j]==2)
printLCS(i-1,j);
else
printLCS(i,j-1);
}

int main()

{
while (1) {
gets(X);
if (feof(stdin)) break;
gets(Y);
printf("LCS length -> %d\n",LCSlength());
printLCS(m,n);
printf("\n");
}
}
[/sourcecode]

The DP code above moves bottom-up. It solves all the subproblems. Sometimes it may not be required to solve all the subproblems but only a few of them. This is what the memoization techenique does. Look at the code using memoization below:

Memoization Technique (Top-down):

[sourcecode language="cpp"]
int max(int a,int b)
{
if(a<b)return b;
return a;
}

int lcs_memo(char* x, int n, char* y,int m)
{
int memo[n+1][m+1];
int result=0;
for(int i=0;i<=n;i++)
for(int j=0;j<=m;j++)
memo[i][j]=-1;

/*base cases*/
if(m==0)return 0;
if(n==0)return 0;

/*see if already calculated*/
if(memo[n][m]!=-1) return memo[n][m];

/*if not calculated, calculate now*/
if(x[n]==y[m])
result=1+lcs_memo(x,n-1,y,m-1);
else
result=max(lcs_memo(x,n-1,y,m),lcs_memo(x,n,y,m-1));

/*save result*/
memo[n][m]=result;

return result;
}

[/sourcecode]

The LCS code above (both DP and memoization techniques) takes O(n-square) time and O(n-square) space . It is possible to write a little more efficient code for LCS . The time complexity is the same (or probably a little higher in terms of bigger constants) but the space complexity can be reduced to be linear . Check the code  here . Note that the LCS is not unique. If you want to find all the LCSs see the pseudocode at wiki. Lastly, lcs can also be found using the edit distance algo by making the cost of replacement greater than that of an insertion plus a deletion.

LONGEST INCREASING SUBSEQUENCE

LIS, I would say , is a cousin of LCS  It stands for   Longest increasing subsequence.  The problem statement is as follows:

Given a sequence a_1, a_2, \ldots, a_n, find the largest subset such that for every i < j, ai < aj.

This wiki article explains the problem statement  pretty nicelyAn interesting way of finding the LIS is to use the LCS algorithm.

  1. Make a sorted copy of the given sequence (say A), denoted as B. This would take O(nlog(n)) time.

  2. Use LCS on A and B which takes O(n2) time.


Alternatively you may solve LIS without using the LCS algo , The straight-forward DP approach is explained nicely by the algorithmist . The LIS problem comes in two different flavours :

  1. Find the length of LIS ,

  2. print the LIS .


If you need only the length  its the easy part . The second part is a little trickier . Also ,the LIS implementation can be done in O(n-square) or 0(n log n ) time .Here is an O(n log n) code to find the length of LIS.

[sourcecode language="cpp"]
#include<iostream>
#include<set>
#include<vector>
using namespace std;

int LIS(vector<int> A)
{
int N = A.size(),i;
set<int> s;
set<int>::iterator k;
for (i=0;i<N;i++)
{
if (s.insert(A[i]).second)
{
k = s.find(A[i]);
k++;
if (k!=s.end())
s.erase(k);
}
}
return s.size();
}
[/sourcecode]

The above code runs in O(n log k) time where k is the length of the LIS found . To  get the LIS itself ,  we need to maintain a previous array which stores the index of the previous element in the LIS. Here’s a C++ implementation. It returns the LIS as an array.

[sourcecode language="cpp"]
#include<iostream>
#include<map>
#include<vector>
using namespace std;

typedef pair < int , int > PI;

vector<int> LIS(vector<int> A)
{
int N = A.size(),i,j=-1,t;
vector<int> pre(N,-1),res;
map<int,int> m;
map<int,int>::iterator k,l;
for (i=0;i<N;i++)
{
if (m.insert(PI(A[i],i)).second)
{
k = m.find(A[i]);
l = k;
k++;
if (l==m.begin())
pre[i]=-1;
else
{
l--;
pre[i]=l->second;
}
if (k!=m.end())
m.erase(k);
}
}
k=m.end();
k--;
j = k->second;
while (j!=-1)
{
res.push_back(A[j]);
j = pre[j];
}
reverse (res.begin(),res.end());
return res;
}
[/sourcecode]

If you are not very familiar with STL (in C++) , you may go for the O(n-square) solution . Here is a C code I generally use .

[sourcecode language="cpp"]
#include<stdio.h>
#include<string.h>
void lis(int str[],int n)
{
int len[n],prev[n],i,j,max=-1,k,b[n],a=0;
for(i=0;i<n;i++){
len[i]=1;
prev[i]=-1;
}
for(i=1;i<n;i++)
for(j=0;j<i;j++){
if(str[i]>str[j]&& len[i]<(len[j]+1)){
len[i]=len[j]+1;
prev[i]=j;

}
}
for(i=0;i<n;i++)
if(len[i]>max)
{ max=len[i]; k=i;}
b[a]=str[k];
for(i=prev[k];i>=0;i=prev[k])
{b[++a]=str[i];k=i;}
for(i=max-1;i>=0;i--)
printf("%d ",b[i]);
}
main()
{
int str[]={5,9,4};
lis(str,sizeof(str)/4);
return 0;
}

[/sourcecode]

Play with my codes if you dont understand it  . Try different inputs .  If you  still dont get it , feel free to drop a comment .

References:

  1. I came to know of the the LIS codes (O(n log n) versions)  presented above from here .

  2. Art of programming (viz - no. 2 here).

  3. geeksforgeeks.org article for LCS

  4. http://www.ics.uci.edu/~eppstein/161/960229.html

Monday, February 6, 2012

The Starting Dilemma !!!

As I thought of starting with my first blog today ,  I looked around for topics to write about ,thought of a number of things but i could not  find the best one  to start with . But then I found  this question .... why am i not able to decide ??? probably the

THE STARTING DILEMMA ,    In my head, I'm finished. In reality, I haven't even started !!!

Its been a long time since i first told myself -  " well,  I should start blogging !!! " . If wordpress is to be believed , I registered on the site in Jan 2011 .  Its been more than an year . All these days   I used to tell myself  " had I been blogging , I would have definitely posted one today " ,  only to find that I am in no mood to start today and finally forget about it :P.

I think I can safely presume  that I am not the only creature of  this kind  . Very Often , We do this thing where there is something we want to start.  we come up with the idea, plan it, do a bit of research[or probably just a tad :D] . We  have everything planned to start , then we plan it more extensively, and how it will turn out in the end. I anticipate how I will view it, and how others will, and think about the themes and what it means. In the end, I have a wonderful plan but I haven't started.
We  love to start things, but sometimes we think about them too much, we  plan and try to perfect them , finish them in our head but we forget that we  never actually started something to accomplish.

But I have put it to an end . This may not be the best start I could have come up  with , but the most important thing is that I have started  and now i can follow it up with all kinds of things :)