Monday 24 September 2012

Lecture Motivated Me : Ram Kedlaya @ IIT Delhi

25 Sep., 2:00 am

Just finished motivational lecture by Ram Kedlaya an alumni of IIT Delhi and founder of Tminus company.
according to him Tminus stands for

T - TIME
M- MENTOR
I - INTERDEPENDENCE
N- NEWNESS
U - UNIVERSALITY  
S - SPARK

Really motivated me shared some of the good stories
He inspired me in the way that, you should be a very good story teller, very good communicator, you should have great networking skills and obviously sharing is very important whatever you learn just share it with others and also nice concept of reverse mentoring.

During his talk he spoke about lot of guys who some how inspired him during his lifetime. I did google search on them-

About the guys he talked in his presentation were

1. Arvind Kejriwal -  Extremely talented guy. You all know about this guy but how Ram Kedlaya described him is as a man who grasped all the concepts given by Gandhiji and applied them very nicely and executed in the form of actions.

In the meantime i also watched speech given by arvind kejriwal @ IIT chennai, and also watched some of his interviews about "JAN LOKPAL BILL". 

2. Gandhiji- A shrewd lawyer by profession, the one who have his mind and heart both aligned.

3. "The last lecture by randy paush"   just give it a search on youtube

4. Michael Jordon - One of the greatest basketball player in the world

5. Google start up story

6. Vinod Khosla IIT Kanpur guy and multi billionaire now, a well known person in silicon valley

7. Ram Kedlaya's own start up story.

Simply liked it...

Let us contribute. 

Sunday 23 September 2012

Google Written Test 21 Sep. 2012,IIT Rajasthan

Third party conducted test on behalf of Google @IIT Rajasthan. 

This is effort of  my colleagues and B.tech guys. I have not included answers of  questions, also i can't claim that my answers are 100% accurate :) though we can discuss. 

Questions asked in Google written test  (21st Sept, 2012 of 70 minutes) 

(30 minutes for objective questions and 40 minutes for programming questions)

Objective questions (18 questions in 30 minutes):

1. How many distinct BSTs are possible for 6 distinct numbers?

(A) 128
(B) 132
© 720
(D) 120

2. Inorder and Preorder Traversals of a tree were given. Find the Postorder Traversal.

3. Which one of the given grammars is regular?
a. (wwr)
b. (wawr)
c.
d.

4. 2 or 3 scheduling questions. (LRU), optimal page replacement policy

5. Find the time complexity of a recursive algorithm.

6.  We are given a set X = {x1, x2, ..., xn} where xi =  2^i. A sample S (which is a subset of X) is drawn by selecting each xi independently with probability pi = 1 / 2. The expected value of the smallest number in sample S is
(A) log n
(B) 2
©  n
(D) √n

7. Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q is polynomial time reducible to S and S is polynomial-time reducible to R. Which one of the following statements is true?

a) R is NP-complete
b) R is NP-hard
c) Q is NP-complete
d) Q is NP-hard

8.

if(fork() && fork())

fork();

if(fork() || fork())

fork();

printf(“hello\n”);
how many times hello will be printed?

9. which of the following languages can be solved using DFA
 (a^n)(b^n)\
 (a^n)x(b^n)
 (a^n)(b^n)x
 x(a^n)(b^n)

10. 1 question from computer architecture.

11. Three processes with process ids 0,1 and 2 with their CPU burst times 2,4 and 8 time units respectively arrive at the CPU at t=0. If the Longest Remaining Time First (LRTF) algorithm is followed, what will be the average turnaround time for these 3 processes. In case of a tie for 2 or more processes, the process with smaller process id is given the priority of executing first.

(A) 11 units
(B) 12 units
©   13 units
(D) 14 units               

12. What the following code does:
bool SomeFunction(unsigned int v)

    {
    return (v!=0) &&  ! (v & (v-1));
}

a) odd number
b) power of 2
c) number contains a 0 digit
d) multiple of 2 

13. A simple graph is one in which no two vertices are connected by more than 1 edge and neither does it contain any cycle. Given a simple undirected graph with 6 vertices which of the following can be the only possible set of degrees corresponding to the vertices of the graph?
(A) {4,4,2,1,1,1}
(B) {4,4,2,2,1,1}
© {4,4,2,2,2,1}
(D) {4,4,1,1,1,1}           

14. An array A has 7 distinct numbers. It has to be splitted into two arrays B and C such that B contains 3 numbers and C contains 4 and atleast one of the arrays should be sorted in increasing sequence. How many possible combinations of B and C are possible?
(A) 30*(7C4)
(B) 29*(7C4)
©   28*(7C3)
(D) 32*(7C4)


15. Two numbers are chosen at random from the set {1,2,3}. What is the expected value of sum of these numbers?

(A) 4
(B) 5
© 4.5
(D) 3
 

16. What is the time complexity for finding the GCD of nth and (n+1)th Fibonacci Number using Euclid’s Algorithm?
(A) log(log(n))
(B) log(n)
© n
(D) n^2        

17. How many minimum states do you need to draw a DFA of strings which include a’s that are divisible by 6 and the number of b’s divisible by 8?
(A) 8
(B) 14
© 24
(D) 48      

18. There are n stations in a slotted LAN. Each station attempts to transmit with a probability p in each time slot. What is the probability that only one station transmits in a given time slot?
(A) (1-p)^(n-1)
(B) np(1-p)^(n-1)
(C) p(1-p)^(n-1)
(D) 1-(1-p)^(n-1)   


40 minutes for this programming question given below-

----------------------------------------------------------------

Programming question: (Language could  be  C,C++,Java. An optional component of logic presentation was also there)

There are n dice each with m faces numbered from 1 to m. Given a number x, find out the probability that the sum of all numbers obtained from the n dice in a trial is greater than x. All dice are fair. A function double winningProbability(int n, int m,int x) was to be written.

This question can be divided into two cases, n<=m and  n>m.

Case 1: When n<=m,

Probability=(1-xCn/k), where k=m^n.

Case 2: When n>m,

Wednesday 19 September 2012

" Install Greasemonkey and try some scripts in your browser"

Today i was browsing and got to know that you can use scripts to give extra functionality to some particular web page or particular websites and ride and drive them according to you. I mean the code or script you write that drive the functionality of that page.   

 for example

1. Suppose in you tube you want a download link right below the video so that you can download it in mp4 video format or some other formats.
 You don't have to go to some other websites to download youtube videos, Or you don't have to download and install youtube video downloader.
The particular script will enable a download link below your video and just by clicking it you can download video.
Greasemonkey will execute this script for you. (* I am explaining about greasemonkey below). 

2. Signout from your gmail account automatically within some prescribed time limit (decided by you).

3. In facebook if you go on chat id's you can see there big pictures and images on the left side of the page.
and many more.

  So there are two things you need to make the things work-
1. you want script (code) that drives functionality. Extra Functionality in the form of code. 

and the

2. second thing is execution of the script in your web browser that is done by installing greasemonkey addon.

We will follow the above stated procedure but second  option first, first install greasemonkey addon required to execute script in web browser and then after install script or manually add source code of script into the web browser.    

Note I am illustrating it on FireFox web browser only, if you use another browser then there are some other extensions like greasemonkey in firefox same like tempermonkey in googlechrome.

So start,
For adding these functionality for particular pages and websites in your web browser, first you have to install Greasemonkey addon it is simple  : I am talking about greasemonkey an addon on firefox.

Greasemonkey add on is required because it executes your script in web browser fine. 

STEP 1:
Just go to the site Greasemonkey  click Add to firefox button
and you will get greasemonkey addon installed on your computer.  

The top right most sign of monkey near your link bar signifies that greasemonkey is installed on your computer. There is drop down button just near that monkey sign, where there are options to enable and disable greasemonkey and etc. 

STEP 2 :
Now you require some cool scripts to run on.
Just search some scripts on this link
and install any script you like in your browser  it is simple just click install button.

Second way to install script after installing greasemonkey.
This is from source code also you can install these scripts.  just save source code by         
                 filename.user.js extension.
                    keep attention on .user.js extension

open this file in your web browser by going on file open and it will prompt to install your script on the web browser.
as greasemonkey is installed on your computer so just install the script and you are done the new functionality has been added to the browser.
You can manage the script remove by going in tools->greasemonkey and then manage scripts
from there you can remove disable and set preferences to the scripts that you installed.

If you have problem in setting up scripts then can comment. I will try to sort out the issue

Cheers and Give it a try, it's cool and try to make your own scripts too..

Wednesday 5 September 2012

More on LaTeX : History and Motivation

LaTeX is a highly efficient document preparation system developed by Leslie Lamport. It all started when the legendary author Donald Knuth was writing the second volume of The Art of Computer Programming. The lack of a good type-setting system led him to develop Tex and release it as free software. LaTeX can be thought of as a Tex extension intended for UNIX systems. Like Tex, LaTeX is also free software, released under the LaTeX Project Public License (LPPL).

Why use LaTeX ?

One of the main advantages is that it helps typeset documents beautifully, especially technical documents:
Mathematical formulas can easily be constructed using certain commands.
  1. Being a programming language, a user can easily modify its default behaviour.
  2. The availability of professionally crafted inbuilt layouts make a document really look as if printed.
  3. Documents in PS, PDF formats can be easily generated.
 
 Classes and Packages:

Like the Linux mechanism of extending kernel features with modules, LaTeX provides classes and packages for extending behaviour. A class is used to modify a document style. Beamer is one of the most popular LaTeX classes for creating presentations. Prosper is another widely used presentation-making class.

Packages can be added and used inside a document class. A package is used to provide some additional functionality to an existing document. For example, if we need to insert a picture, we have to include the graphics package. For a document, there can only be a single class, but many packages can be used inside a class. Some commonly used packages are:
  • amsmath — Mathematical formula formatting — \usepackage{amsmath}
  • graphics — Handling imported images — \usepackage{graphicx}
  • fancyhdr — Used to insert custom headers — \usepackage{fancyhdr}
  • makeidx — Used to build an index for a document — \usepackage{makeidx}
  • fontenc: Handling font encodings — \usepackage[encoding]{fontenc}
 

Updatation of tex-live package for LaTeX : More Tips

Updatation of TexLive package- (for unix, linux flavors and mactex)

all tex live distribution contain

1. binaries
2. packages and classes

for updating tex live there is separate update schedule for both of these. The TeX Live binary part of the distribution undergoes a major update only once a year, while the packages can be updated constantly.

if you have for example TeXLive 2011, you can update its packages roughly until TeXLive 2012 is created. After that point, your 2011 system will not be able to update any packages ever again using the normal package manager. (You can update individual packages manually via CTAN, of course.)

Binaries updates available once in a year and once it is out you have to update like you have to install distribution fresh, now you would not be able to update the packages but manually packages can be updated via CTAN. 
for more refer to

http://tex.stackexchange.com/questions/55437/how-do-i-update-my-tex-distribution


Continuation my previous post on latex, i just want to ensure that i am using the latest version of tex-live as  i checked using
                                     $tex --version
 i got to know that i am running tex-live 2009 version and 2012 is already there on TUG website.

So i checked why is it so and i deciphered that by default if you install tex-live using
               $sudo apt-get install tex-live
it will install tex-live version 2009


for testing which version of tex live you are running on your machine use
                   $tex --version
 it will return version of tex live you are using


Now for installing tex-live version 2011 on your machine follow following steps-
Although the most recent version of tex-live is tex-live 2012.

STEP : 1
To install TeX live 2011 on ubuntu 11.10, download the installer “install.tl” from
 http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz

STEP :2
Extract the package. Now open terminal, and go to the directory where the folder is extracted. In the extracted folder you will have “install.tl” file, which is a perl file.
                             Now, give the command
                               “sudo perl install.tl”




Sunday 2 September 2012

Doxygen : Documentation of your Source Code

If you are working on big projects then documentation is very important for keeping your audience skilled and make them understand about your development.

There are various automated tools that automatically document your code. Moreover from the comments that you put up in between your code that are taken by these tools and used in your documentation. These tools make tex files, html pages for your software code automatically. There are many automated  tools  available some are

                             Javadoc - specifically used to document java code.
                             doxygen- c,c++,java and document code in various languages

some of the tools and their comparative feature are stated on this wikipedia link

http://en.wikipedia.org/wiki/Comparison_of_documentation_generators

just visit this link and have a look on various features.

I have settled up doxygen for documentation of our project on my Linux machine.

Installation of Doxygen-
1. Directly you can install it from synaptic manager. There is separate package available, atleast i know above Ubuntu 11.04 it is available as separate package and you can download and install it from Ubuntu Software Center.

2.if you want to install it using binary installation then you can download doxygen from
               http://www.stack.nl/~dimitri/doxygen/download.html
on this link binary distribution is available this is compiled code for the software for linux and windows.  You just have to extract it and make it install on proper place.

Using Doxygen-

1. Creation of doxyfile, that is a configuration file where you configure for the documentation. 
for creating doxyfile just go into the main directory of your project and
use

$doxygen -g
(A doxyfile configuration file is created with the name doxyfile)

$doxygen -g filename
doxygen configuration file is created with the name as filename

 2. Now doxyfile has been created you have to set or configure various parameters in this doxyfile, just study this doxyfile and set various parameters according to your requirements.

3. For compilation use

$doxygen
this command will compile your doxyfile and generate, two directories name
html and latex.
these directories will contain the documentation in the form latex file and in the form of webpage.

Important thing is to set various configuration parameters in configuration file, like path of  source files, files you want to document etc. etc. just have a look on
doxyfile created using the command $doxygen -g
and you will get to know various parameters you have to set. ...

Another important thing is coding style and adding comments in between your source code. There is specific style for writing the comments so that doxygen can compile it and take out the comments and convert them in the proper documentation.

If you have doubt can comment. More finer details like how to set various parameters of doxyfile would be discussed in next posts.

 "Happy documentation"........