Sunday 2 November 2014

Questions for starters...

1) What should be the output of the following?

#include<stdio.h>
int main(){
   int result=68;
   result++;
   printf("%d\n", result);
    /*
    ++result;
    /*
    result++;
    */
    */
   printf("%c\n", result);
}

Friday 1 August 2014

Whats up with modulo (10^9 + 7) ?



Many times I have seen contest sites asking for not the actual answer but a modulo of the answer with something weird like (10^9 + 7). But why do they do that? And why only this number?
The reason is obvious, "Integer Overflow Error" !!! The next obvious question is why this number only?
Isn't it ok to get the last few digits of the final answer(say ans)? Its ok but the chances of clashes are too high. So we will take the modulo with 2^32 or 2^64 depending upon our range(int or long). However there is a serious problem here.
Suppose we are asked to find the value of (5000!), now this means that there will be atleast 500 zeros at the end of the answer. And when we take (ans mod 2^32) we will get 0 as the final answer. And that is where people can cheat. So the solution to that is to use a prime number for doing the modulo.

Wednesday 30 July 2014

The food you steal everyday.

        Its 1 pm at office and we are out in the cafeteria with our friends. We fill up the plate and while doing so we are either talking or hoping the food to taste good. While we are doing so almost 842 Million people are struggling with hunger everyday. And we are one of the reasons for that.
        Everyday I see so much food wasted just because we are not paying attention to how much we are putting in our plate. People are dieing out there of hunger just because you are not sure how much you want.

        While at college also I would see so much food wasted because of the same reason. Everyday the amount of food can be used to feed at least 30 people twice a day. Then why are we not doing that? The thing is we are not doing it on purpose. Its just that we don't know how much hungry we are. One of my friends Sudeep from college told me a beautiful trick to stop it. He said,  
 "What ever you put in your plate finish it ! No matter what. Force feed yourself. So that next time you will take a lesser amount. And after a week or so you will know just the right amount you need. Its simple, we learn best from our mistakes!"
        Sometimes I would see him sitting in the mess trying to finish the food. He will sit there just waiting for food in his stomach to settle down so that he can eat the rest. But no matter what, he will finish it. I also tried the same approach and it worked for me.
        Yet another strategy that I saw at IITK was to put a notice near the food counter telling how much food was wasted yesterday and how many could have been fed by it
        Also just take a little amount in a spoon, taste it and decide whether you want it or not. Its time we stop blaming the government for not fixing the poverty. As Pope Francis said, "Throwing away food is like stealing from the table of those who are poor and hungry".

Friday 25 July 2014

An answer to "How can I prepare myself to be a software engineer at Google?"

The following post was originally posted at: here.

Question:
How can I prepare myself to be a software engineer at Google?

Answer:
Important Points from a Googler's Perspective.
  • Before I provide you the list of courses, read Point 1, 2.
  • Full-time working professionals—Read this answer "selectively" on the basis of your industry experience and academic knowledge.
  • Pre-University Students—Skip everything and Jump to Point 7.


Point #1: Lets Get to the actual Question i.e.

How can I prepare myself to be a "good" software engineer?

Yep! Rest of the question is optional. Joining Google is not a moonshot. Any Good software Engineer has Good chances to be part of Google work-culture.
Problem is how you define "Good".
Point #2: Attitude Adjustment.

Before you impress recruiters at Google, Lets see if a software engineering role at Google is something you actually want.

Software engineering is not as fun as the popular notion says about it. Apart from UI/UX positions, in general, no matter what text editor you use—Eclipse, Vim or Emacs—Your screen will be Black, Boring & Dull. A full-time software engineering role not only requires an ability to work on complex algorithms but enough tolerance and patience to focus on meticulous details of a large program.

At Google, in general, most software engineering role comes down to nothing but mathematics. It doesn't matters how many languages you know or How cool you are with Java, C, C++ etc.

What matters are these four objectives:
  • Your ability to create efficient algorithm.
  • Your meticulous skills to read codes written by others and spot issues in it, if any.
  • Your curiosity to learn and implement new technology trends and adapt with demand.
  • Last but most important: What you Build, how you Build?

I must point out that attaining these four objectives is not easy. Most of us at Google have hard time reaching these objectives but we try, so should you.

Everyone has different approach towards learning. For me, I read one research paper links I find on Quora(May/May not be related to CS) and one research papers at Google(Internal records)—everyday.

When you join Google, you will have access to all code base, database, forums, research papers and projects which will provide you a great support in learning things which you won't find on Wikipedia...

...but while you are preparing on your way to be at Google, there are few things which are common in the process of learning. In point #5, you will learn more about it—how to reach these four objectives—but before there're some pre-requisites that needs to be looked upon. So, Lets go to next step. i.e.

Point #3: Guide for Technical Development in 2014—From Google.

Having a solid foundation in Computer Science is important in being a successful Software Engineer. Following guide from Google is a suggested path for University students to develop their technical skills academically and non-academically through self paced hands-on learning. You may use the following course guide to determine courses to take but please make sure you are taking courses required for your major or faculty in order to graduate. The online resources provided in this guide are not meant to replace courses available at your University. However, they may help supplement your learning or provide an introduction to the topic.
Using this guide:
  • Please use this guide at your discretion
  • There may be other things you want to learn or do outside of this guide - go for it!


Point #4: Recommendations for Academic Learning






Point #5: Recommendations for Non-Academic Learning

  • Work on project outside of the classroom.
    Notes: Create and maintain a website, build your own server, or build a robot.
    Online Resources: Apache List of Projects, Google Summer of Code, Google Developer Group
  • Work on a small piece of a large system (codebase), read and understand existing code, track down documentation, and debug things.
    Notes: Github is a great way to read other people’s code or contribute to a project.
    Online Resources: Github, Kiln
  • Work on project with other programmers.
    Notes: This will help you improve your ability to work well in a team and enable you to learn from others.
  • Practice your algorithmic knowledge and coding skills
    Notes: Practice your algorithmic knowledge through coding competitions like CodeJam or ACM’s International Collegiate Programming Contest.
    Online Resources: CodeJam, ACM ICPC
  • Become a Teaching Assistant
    Notes: Helping to teach other students will help enhance your knowledge in the subject matter.
  • Internship experience in software engineering
    Notes: Make sure you apply for internships well in advance of the period internships take place. In India and US, Internships take place during the summer, May-September, and applications are usually open several months in advance.
    Online Resources: google.com/jobs





Point #6: Google Recommended/Sponsored Programs and Groups.

Few Additional Course you may choose to subscribe with respect to your domain or interest. These courses and programs are a great place to learn but they don't increase or decrease your chances to join Google—They are not equivalent to Internship. (More Info from Robert Love)

  1. Google Course—Making Sense of Data
    This self-paced, online course is intended for anyone who wants to learn more about how to structure, visualize, and manipulate data
  2. Google Course—BOLD Discovery
    This two-day interactive conference will provide students between their first and second years of college with an introduction to Google culture and potential careers at the company.
  3. Google Summer of Code
    Google Summer of Code (GSoC)
    A global online program offering post-secondary student developers ages 18+ stipends to write code for various open source software projects.
  4. Google Policy Fellowship
    This program offers students the opportunity to spend the summer working on Internet and technology policy issues at public interest organizations
  5. Google Student Veterans Summit
    The Google Student Veterans Summit includes a professional development curriculum geared towards veterans' transitions into the workplace.

Also Read: Ellen Spertus's views on How can I effectively use my last two years of college to prepare for a great Software Engineering job at Google/FB or a startup?





Point #7: Recommendation for Courses in Mathematics.
(For Pre-University Students)

Personal View: Any attempt to ignore these subjects will put you in the category of average programmers who learn things in completely wrong way.

Staying prepared much before would make coding much more enjoying. There are few pre-requisites for a software-engineers which would help you to understand the core of algorithm. Most mistakes created by software engineers could have been avoided if they would've recalled the simple things from school education.

In your further studies in Maths or Computer Science, You will realize the importance of "Data Structure in your college days" and importance of "Machine Learning in your post-graduate days". So, Following are detailed list of courses you must master in-order to design complex algorithms. For college-graduates, if you had ignored these subject, I highly recommend you should revise it in the best possible way you can.

After you're done with introductory syllabus from your school books, practice the following courses for deeper understanding. Most college students (even working professionals) underestimate the importance of these courses and end up being just another average programmers:



Pre-University: Google Recommended/Sponsored Programs.

  • Google Code-in (GCI)
    A contest introducing pre-university students, ages 13-17, to the many kinds of contributions that make open source software development possible.
  • RISE Awards
    Google RISE is a partnership and awards program designed to promote and support STEM and Computer Science education initiatives for K-12/Primary and Secondary/Class 10th and 12th students around the world.
  • LEAD Computer Science Institute (LEAD-CSI)
    This program exposes middle and high school students from diverse communities to colleges and careers in the Science, Technology, Engineering and Math (STEM) fields.
  • Made with Code
    Coding is the new literacy - it carries the potential to create, to innovate, and quite literally change the world. This initiative is designed to inspire millions of girls to experience the power of code.
  • High School Symposium
    This is a one day program designed to provide high-achieving high school seniors with valuable business skills before starting college.
  • Trailblazer
    Trailblazer is a global network of leaders, advocates, and ambassadors for computer science education who will be charged with empowering youth and educators around the globe to be connected to and inspired by computer science.
  • Google Science Fair
    The Google Science Fair is a global competition open to 13-18 olds. Students submit a project online for a chance to win amazing prizes.
  • Computer Science Summer Institute (CSSI)
    CSSI is a 3-week summer program for incoming college freshmen (current high school seniors) who are interested in studying computer science.
  • Maker Camp on Google+
    30 days of Do It Yourself and making. Maker Camp is a free virtual summer camp on Google+, open to all
    Maker Camp 2013: Supercharge Your Summer!
  • Connected Classrooms
    Collaborate with teachers and education organizations to offer experiential learning opportunities for K-12 students on Google+.





Coming Soon in This Answer:
  • Post-Graduate Students(Majoring in any fields related to Physics, Mathematics, CS)—Answer will be updated this Friday.
  • PHd students(Research in the field of Physics, C-Neuroscience, Maths, CS)—Answer will be updated this Friday.

Tuesday 22 July 2014

My heart burns like fire

Soyen Shaku, the first Zen teacher to come to America, said: "My heart burns like fire but my eyes are as cold as dead ashes." He made the following rules which he practiced every day of his life.
  • In the morning before dressing, light incense and meditate.
  • Retire at a regular hour. Partake of food at regular intervals. Eat with moderation and never to the point of satisfaction.
  • Receive a guest with the same attitude you have when alone. When alone, maintain the same attitude you have in receiving guests.
  • Watch what you say, and whatever you say, practice it.
  • When an opportunity comes do not let it pass by, yet always think twice before acting.
  • Do not regret the past. Look to the future.
  • Have the fearless attitude of a hero and the loving heart of a child.
  • Upon retiring, sleep as if you had entered your last sleep. Upon awakening, leave your bed behind you instantly as if you had cast away apair of old shoes.

Thursday 29 May 2014

Tips for campus placements



Final year, mails from TPO and frustration, thats what is common to every final student in every college. While it does matter what you have studied in the past few years but still there is a lot of time to patch up your knowledge.
I have been doing TA duties for almost 2 years and almost every student asks this question from me, " How to prepare for the placements?". So here are some tips for the placements.

  1. Resume/CV: They say first impression is the last impression. Resume is your first move against the interviewer. It should be crisp, clear and should highlight how you are different from the ones standing outside. Don't put any skill in it unless you actually know it like, don't put Linux as your skill if you barely even turn it on. Take help of Google in this case.
  2. Subjects: Data Structures, Algorithms and C these three are the must know. Even if you don't mention them in your resume interviewer is going to ask from them anyway. Apart from these Operating Systems is also important. Most companies focus on OS, they start from definitions and end up asking you code for signaling, pipes etc. A word of advice for people who think they know Computer Networks, please don't mention it explicitly. It is very vast and you will most probably end up not answering most of the questions. So if you are good at CN then don't mention it rather let the interviewer decide whether to ask or not. In this way if he asks normal level question you will be able to answer and that will give you +ve points. Rest its upto you :D.
  3. Projects: Add all the projects you have ever done. Whenever interviewer asks about your project throw everything you know at him (don't start bragging though). Its an open ended question. You can even add stuff that is not the part of the project, provided you know it now. He is not gonna check your reports.
  4. MOOC: A subject out of the coursework is very helpful. If you can learn a subject, a tool or a new software then its very helpful to set you apart from others. Join a MOOC and earn a certificate. Sites like coursera and edx provide a great platform for online education.
I'll write a post on what books to follow and other Do's and Don'ts. Peace.