Sunday, December 21, 2008

KURUKSHETRA - BATTLE BEGINS

One more year has gone by.. I could say this because the next big thing in my calendar is KURUKSHETRA'09. I never believed in adage. According to me its all crap. But one thing I learnt from Kuruk is "united we stand, divided we fall". All students of our college work together to make this great event. Do check out the website. Lot of online events are open.

the website address is : http://kurukshetra.org.in/

The battle begins on Jan 21st. But registerations open now !!!

Wednesday, August 20, 2008

Quine programs

A “quine” (or “selfrep”) is a computer program which prints its own listing.

complex yet trivial code to print the own source file is

#include
char *p="#include%c%cchar *p=%c%s%c; %c%cint main(){%c%cprintf(p,13,10,34,p,34,13,10,13,10,13,10,13,10); %c%cgetch();%c%c }";

int main(){
printf(p,13,10,34,p,34,13,10,13,10,13,10,13,10);
getch();
}


Lot more about this type of programming in
http://www.madore.org/~david/computers/quine.html

Wednesday, June 25, 2008

Googly Google

Well, just like everybody I was there doing my business, yes browsing through technical blogs for passing time. Trust thats one good freetime job. So I came across this blog, it has informations to help you chat well and also to write Project Management Exams.

http://sanjaykattimani.blogspot.com/

From that blog I came across this Google's yet another invention or what ever it is, Toogle. Nice and bubbly.
Just like Google image search, here the slight difference is the image is drawn with the search string.

Speaking of searches and Google, this feature really helps you if the website you are looking for has no custom Google search.

http://www.google.com/advanced_search
And trust me, it gives better result than custom search.

I will sure update more about Google's products.

Intriguing Puzzles

As I am preparing for my placements, I was on the lookout for books with puzzles to work out and to train the mind to think. I came across this book name in many forums I saw. So when I searched for this book, viola I got a pdf copy of the book online. The book name is Shakuntala- Puzzles to puzzle you. This book is recommended for anybody who is looking forward to Infosys interviews.

P.S : solutions are at pg.89

http://www.scribd.com/doc/2052493/Devi-ShakuntalaPuzzles-To-Puzzle-You

Thursday, June 12, 2008

Puzzles

Interesting how these puzzles make your mind fresh. Anyways, I am right now in a puzzle solving spree.. So I was searching for some websites with puzzles .. and found an excellent website, where I can learn and think,

http://en.allexperts.com/q/Puzzle-Solving-1841/

Trust me, this is good. I am going to blog down the supporting theorems and techniques for later reference.

Bayes Theorem:

P(A|B) = P(AnB)/P(B)

P(A|B) - conditional probability. Probability of A happening given B has happened.
P(A) & P(B) - prior probability.

Multiplication tricks:

Multiplication of two digit number by 11:
The result will be the first digit, sum of the two digit and the second digit of the given number.
Eg: 4_2 is the two digit number. The result would be 462, where 6 is sum of first (4) & second(2) digit.
Given 4_8, the result would be 528, since when we add 4+8= 12 add 1 to first digit, and follow the rule above.

Multiplication of any number by 5:
*Divide the number by 2
*If there is a remainder, add 5 to the answer. Else, add 0 to the remainder.
Eg: 246 * 5 :
246/2 = 123 (no remainder)
So result would be 1230.

Say, given 235 * 5:
235/2 = 117(there is a remainder)
so result will be 1175.

Division Techniques:

Divisible by 4, 8,16:
Any number is divisible by 4, only if the last 2 digits of the number are divisible by 4. Similarly for 8 and 16, the last 3 and 4 digits should be considered.
Eg:
5632 is divisible by 4, since 32 is divisible by 4.
It is also divisible by 8, since 632 is divisible by 8.
It is also divisible by 16, since 5632 is divisible by 16.

Divisible by 3,9:
A number is divisible by 3 only if the sum of its digit is divisible by 3. Similarly for 9, the sum of digits should be divisible by 9.
Eg:
23541 is divisible by 3, since 2+3+4+5+1 = 15 is divisible by 3.
334242 is divisible by 9, since 3+3+4+2+4+2=18 is divisible by 9.

Divisible by 11:
A number is divisible by 11, only if the difference between the sum of its digit in the odd places and the sum of its digit in the even places are either 0 or a number divisible by 11.
Eg:
4832718 is divisible by 11. Since (8+7+3+4) - (1+2+8) = 22 - 11 = 11 divisible by 11.



Wednesday, June 11, 2008

To calculate day of the week

When I was reading through some placement question papers, I found this problem asked quite a few times.
Q: Given a date, we have to find out the day of the week.

Solution:
1) C = 2(3-(cent%4))
where cent = first 2 digits of the century
2) y = year + floor(year/4)
where year = last two digits of the year given
3)m = choose from the table















MonthValue
January 0(leap year-3)
Febuary 3(leap year-6)
March 3
April 6
May 1
June 4
July 6
August 2
September 5
October 0
November 3
December 5

4)sum = c + y + m + date given
5)val = sum%7
6) sun - 0,mon-1,tue-2,... sat - 6, use value and find the day

Sample program:
#include

int leapyearMonValue[] = {0,3,3,6,1,4,6,2,5,0,3,5};
int nonleapyearMonValue[] = {3,6,3,6,1,4,6,2,5,0,3,5};

void calculateDay(int date,int mon,int year)
{
int val,cent,monval,yr,i=3,temp,leapyear=0;
int splitcent[4],wrongInput=0;
if(year%4 == 0)
leapyear = 1;
if(mon>12 || mon <1)
wrongInput = 1;
if(date==30 && !(mon%2) || mon==7 || mon==1)
wrongInput = 1;
if(mon==2 && date>28 && !leapyear)
wrongInput = 1;
if(!wrongInput)
{
while(year)
{
splitcent[i--] = year%10;
year = year/10;
}
temp = splitcent[0]*10 + splitcent[1];
cent = 2*(3-(temp%4));
temp = splitcent[2]*10 + splitcent[3];
yr = temp + floor(temp/4);
if(leapyear)
monval = leapyearMonValue[mon-1];
else
monval = nonleapyearMonValue[mon-1];
val = cent + yr + monval + date;
val = val%7;
switch(val)
{
case 0:
{
printf("day is Sunday\n");
break;
}
case 1:
{
printf("day is Monday\n");
break;
}
case 2:
{
printf("day is Tuesday\n");
break;
}
case 3:
{
printf("day is Wednesday\n");
break;
}
case 4:
{
printf("day is Thursday\n");
break;
}
case 5:
{
printf("day is Friday\n");
break;
}
case 6:
{
printf("day is Saturday\n");
break;
}
default:
printf("wrong calculation\n");
}
}
else
printf("wrong Input... check the date, mon \n");
}

int main()
{
int date,mon,year;
printf("Enter the date in format DD/MM/YYYY\t eg: 14/11/2007\n");
scanf("%d/%d/%d",&date,&mon,&year);
calculateDay(date,mon,year);
getch();
return 0;
}


Courtesy:
Wikipedia

Tuesday, May 27, 2008

Basic Unix Commands

Some commands were practiced in the lab. So since this is just for future brush up during interviews it will have only extra features, basic features I have to try and remember.

Very effective:
  • chmod - changes permission for directories/files. eg: chmod ugo+r+w+x filename - gives u-user,g-group,o-others the permission to read(r),write(w) and execute(x). For directory, execute permission is required.
  • ls - list files in the directory. The options most commonly used are -l which is to print file list with permissions, time modified, user details and the other option -a prints all files including the . and .. directories.
  • ff - find files. This command is used to search for a file throughout all available directories.
  • diff - The command which is really unique to unix. This command compares the two files and prints the differences with line numbers.
  • | - pipe. This allows commands to be combined.
Very Basic:
  • cp - copy command. This copies file from one location/one name to other location/another name.
  • mv - move command. This moves/changes file location or name respectively. One had to be careful, 'cause this results in deletion of the original file.
  • cd - change directory. When typed with no argument, it takes to home directory.
  • pwd - current working directory.
  • wc - word count. The order is lines,words and characters.
  • gzip & gunzip - compression/decompression of files.
  • finger - cmd to print details about user. Finger protocol (network).
  • telnet, ftp, rlogin - used for connecting to outer hosts.
  • kill - kills process forcibly
  • ps - lists the process run by you.
  • du - prints disk usuage.

Monday, May 19, 2008

Placement Preparation

Phew!!!! Exams are over, now starts the amazing race towards my own cubicle somewhere in a company. For starters, its placement preparation time. Right now I am enjoying and also studying which is a lethal combination.With this introduction, I am going to blog down all my materials for later references. First day, we are starting with Algorithms.



When we say algorithm, we have tons for everything.So I am going to start learning the basic algorithms first. I am reading from planetmath.org. Its really good. So much technicality and maths are there.

Today(day 1) I read about selection sort,binary search,insertion sort,bubble sort.


Sunday, April 6, 2008

Intel Internship Interview

I got shortlisted for Intel Internship from out of 116 people who initially submitted their resume with CUIC(Centre for University Industry Collaboration). The interviewer told us he selected those resumes that were different ,interesting and got his attenation, when asked. We knew the shortlisted candidates are going to write some test initially and then the face interview which is on some other day. But the shortlisted teams were asked to come the same day for face interview. We had to run from the lab which was still 12.10 to the CUIC for interview. I was the first person to be interviewed. My first personal interview, I should say, was really great. I was not at all frightened which my seniors told me that we would be. I was really freaking out in the interview place. The interviewer finally told me he found me really good. But since I was the first person, he told the results would be relative. So I guess the 2 students who got selected did well when compared to me. I was upset at first, then encouragement from my family and friends, gave me this new short term goal, to get a internship offer from the next company be whatever it is. I am going to attend all the interviews and going to be busy this summer. I will sure, write about the next experience soon.

Saturday, April 5, 2008

Kurukshetra '08 - Dalal Bull :)

Well what can I say about Kurukshetra '08. It was a huge success. Its just the second year but it had reached all corners of India. After coming to college, the day I felt really proud about myself was the two days I spent with my Dalal Bull team. I dont know I had this urge to work for kuruk and as per the saying "where there is a will , there is a way", I got lot of works. First thing that happened was the Website creation job. One day Bhuvana and Suki stormed into my room and told me they wanted some people for website creation. Since I had no prior experience in website creation, I was little hesitant, then what the heck man, If you dont learn in college when are you going to learn ah? So enrolled my name and we all 6 rolled our sleeves and entered the web desinging world. We spent like a month and every weekend formal meetings to discuss about the progress was held(:D). 6 were divided into 3 teams of 2. My partner was Subashini, who is working with me in almost all projects till now. The final work gained many appreciations from seniors. When they hosted it, we were all flying in the sky. Then came the maketing work, we worked under Niranchana 4th year ECE. We have to call up the list of students given to us and explain them about kurukshetra and to ask some questions and to get some feedback. It was so nice talking to new people like professionals ha ha.. but hey its my second job. Then came the final bonanza, the organising post for the prestigious, DALAL BULL. In the first year Kurukshetra, I volunteered in Dalal Bull, all the 3 days I saw no event than this. The second year I planned to visit all programmes. One day my classmates Rajesh and Thanumalayan, asked me to assist them to organise the onsite Dalal Bull event. I was so excited about it and spent some quality time with the team. Our event was to take place on 2nd and 3rd day.
Okay the day before the first day of Dalal Bull, our coordinator, 4th year mechanical,Kapilesh called all three of us and showed us the venue ie hall no 13 where the computers and LAN has been set up. Rajesh and Thanu has to remain there and install softwares ie PHP and set up the server, since my hostel closes by 9, I came bidding them aideu. Thanu asked me to get some backup softwares the next day , I was to come by 7.30 in the morning to the venue and relieve the others. The next day morning I got some 12 missed calls and messages asking me to come immediately to the hall with windows XP cd, php Xampp installation cd. I called them and found out that the server had windows vista and Xampp is not properly installed in vista. Then I rushed off and found the night was a mess for the boys.
While Thanu went home to get his computer and Rajesh to find some xp system from hostel, I was trying to install Xampp in vista. By simply changing the drive from C to D. The Xampp was up and running in no time. We had some nice laughs afterwards and some appreciation from seniors. That felt good.
The LAN wires were old, but the person assured it will work. When the event started, initially everything went so smooth, that we had no work and were sitting simply overviewing the server activities and the database entries. Then after 3 or 4 hours, everything started to create problem the projector's LAN wire got stomped so had to find new one for that, the server got disconnected from the LAN. But overall the first day had some ups and downs. The ups were there was some 700 to 800 registerations for the event. Really huge turn out at the hall. Volunteers (first and second years) had to work some extra shifts to operate the computers and to manage the crowd.
The second day, same 7.30 but no problem with server this time but with the projector again and its LAN wire. Second day was hectic and everybody got tired pretty soon. But finally the utlimate comedy was the final 1 hour of the game. There was some sudden change in the normal flow and a CEGian got first in the game. Some people started disagreeing with this, but coordinator solved the problem smoothly.
Seniors again gave nice comments about our work. The entire experience gained from the two days was Really a great one. This story only inspired to get the Coordinator post for DalalBull next year. No matter what happens or who coordinates the event, I will make sure next year, Dalal Bull gets the spotlight right from day one. I will write about it next year.

Kurukshetral Terms:
Core - 10 decision heads of Kurukshetra Team, these decision makers are first in hierarchy.(always the 4th years. the selection process is crucial, I am not interested in this positon)
Coordinator - For an event, Coordinator is like core and does all decision making. (usually 4th years. I am so much into getting this positon for Dalal Bull next year)
Organiser - For an event, Organisers are the workers. We are responsible to write the software and to handle the crisis. (I have been this and had a quality experience)
DalalBull - simulation of stock market. There was both online and onsite event. I organised the onsite event.
Volunteers - The people who helps all the above personnels. (I have been this and enjoyed working )

Sunday, February 17, 2008

Microsoft Intern question paper

Well I attended Microsoft Internship written test. The question paper was um..okay. They concentrated more on concepts. The "reading between lines" concept was requried to answer all the questions. We were asked to register first, then assemble for a presentation. The presentation was done by a microsoft personnel (dint tell us his name). There were around 400 students from all over tamilnadu. The written test was conducted for around 2500 students alround India. The presentation was about MS's 3 teams for which the internship program was conducted. They were

  • MS IT global team
  • MS consulting
  • MS IDC(Indian Develvopment Center)

The test started at 11.10 am exactly. The question paper was divided into sections. There were 5 sections. Each section was alloted timings based on I guess.. Importance. The 5 sections were(in order)

  • Analytical
  • Software Engineering
  • C and C++ programming
  • Operating System concepts
  • RDBMS

The question paper for next section is given only after collecting the previous section's paper. The questions were asked to test our understanding level and how well we learnt concepts rather than how we mugged up. Sample questions are:

Analytical:

  • Assign a 6 letter code for employees of a company. A-E(5) characters and 0 - 9(10) digits are to be used, whereas first 3 letters are characters and others are digits. Find the proability that all 3 characters are the same.
  • Given a pie chart find the corresponding number of people... etc.

Operating system:

  • In deadlock prevention, hold and wait can be avoided by which protocol. There are 2 protocols and both were given as options.

C and C++ programming:

  • Enumeration is an Userdefined datatype.
  • List is used instead of array and is preferred when
  1. For sequential access.
  2. For random access and some more options.
  • The default access specifier for inheritance in C++ is ......

Monday, February 11, 2008

Struct && Union

STRUCTURE:

A structure is a group of items in which each item can be refrenced with its own identifier and such item is called "member" of the structure. Aka record and field of the reord sometimes.

Matter-of-fact details:

  • For declaring structures, there are 3 methods
  1. struct { //members }struct_varname;
  2. struct struct_tag {//members} ; struct struct_tag struct_varname;
  3. typedef struct {//members} TYPENAME; TYPENAME varname;
  • the typedef declaration sometimes used to achieve the flavor of ADT specification within a C program.
  • A member of structure may be declared to another structure. Eg: struct var1{ struct var2; struct var3; };
  • ANSI standard C allows assignment of structures of the same type. But the original C developed by Kernighan and Ritchie doesnt allow this type of assignment but the field wise assignment.
  • Two structures cannot be compared for equality in a single operation in C.
  • Same identifier can be reused to name members of different structures. No ambiguity caused because while refrencing, the memeber name is followed by the structure name.
  • Amount of memory specified by the structure is the sum of the storage specified by the members of the structure.
  • There are boundary restrictions in some system. For eg: if there is a member of integer, it will start from memory location which is divisible by 4 (assuming integer occupies 4 bytes).

UNION:

C allows another type of structure, the union, which permits a variable to be interpreted in several different ways.

SPOJ Techniques

SPOJ online judge is one of the judges which is used by many of the college students. So far only few problems are solved, many techniques have been learned from mistakes. When the solution is submitted the judge gives the result in code. The code has to be interpreted as follows:

1. AC - accepted - your program ran successfully and gave a correct answer

2. WA - wrong answer - your program ran successfully, but gave an incorrect answer

3. TLE - time limit exceeded - your program was compiled successfully, but it didn't stop before time limit

4. CE - compilation error - your program couldn't be compiled; compiler's errors can be seen from www and are sent via mail if your preferences say so; note: only some languages can give CE, syntax errors in intrerpreted languages can lead to WA (Python - no pre-checking syntax or Perl - CE only afer a basic syntax check)

5. RE - runtime error - your program was compiled succesfully, but it exited with an error; possible codes are:
- SIGSEGV (signal 11) - most common, "segmentation fault"
- SIGXFSZ (signal 25) - "output limit exceeded"
- SIGFPE (signal 8) - "floating point error", like division by zero, etc.
- SIGABRT (signal 6) - raised by the program itself; C++ STL does it under some conditions
- NZEC (non-zero exit code) - helps telling crash from WA with interpreted languages
- other - there are other signals which can cause program to terminate, all remaining are shown as other

problems solved:

In the future, the techniques for string manipulation with code will be updated :)

DataStructures

DATA TYPE:
A method of interpreting a bit pattern.

ABSTRACT DATA TYPES:
Tool for specifying the logical properties of the datatype. Its java counterpart is interface. It declares the methods,but the implementation details are not mentioned and can be changed according to the context of the class that implements the interface. Hence here, it defines the logical properties abstractly.
Eg: For array,

ADT definitions:

abstract typedef <> array(ub,eltype);
condition type(ub) == int;

This specifies that array in C will have two arguments one is ub(upper bound) and the other is eltype(element type). Upper bound is specified to allocate that many number of contiguous memory locations. The element type specifies which type of element each mem. location is going to hold.
This can be extended to other language array representation with some details. For eg in Pascal, int arr[-3..10] specifies both upper bound and lower bound for the array along with eltype of int. Thus ADT would be sth like

abstract typedef <> array(lb,up,eletype);
condition type(ub) && type(lb) == int;

DATASTRUCTURES:

COMPOSITE OR STRUCTURED DATATYPES:
These are made up of simpler data structures. One such datatype is array.

ARRAY:
Array is a finite ordered set of homogeneous elements.

finite: Only finite no. of elements can be stored in an array.
ordered set: the elements are arranged.
homogeneous: may contain one datatype or the other but not the both.

we know in C, int a[10] declares a continuous memory locations starting from a till a+10*sizeof(int). The base (a) is a pointer to the starting location of the array. The disadvantage of the array is that it contains homogeneous elements. But it the simplest form of storing large value.
Another disadvantage interms of efficiency, while dealing with large number of inputs, the insertion and delete all are difficult or atleast will not be efficient.Mutlidimensional arrays are viewed as single dimensional arrays stacked together. The array can be represented as row-major representation where a[2][1] is represented as,

--------
|a[0][0] |
--------
|a[0][1] |
--------
|a[1][0] |
--------
|a[1][1] |
--------
|a[2][0] |
--------
|a[2][1] |
---------

I am BACK!!

Back after a long time. Got lot of things to pour in. Things swamped in
the first in, first out fashion.









Though we dint make it into the shortlisted teams, the experience was a piece of cake. Sitting around the table as in meetings(though haven't seen real meetings, I have picture of it from the films), discussing the pros and cons of every idea about the product gave us real insight into the product development details. Our product was Green Paper. Not to be confused with the Green paper- government's tentative report. Our aim was all about going paperless by providing secure storage and cataloging of receipts and documents online and sharing them with anyone who has internet connection. The motive behind the product is the complete digitization of paper receipts and documents which in turn reduces vast consumption of papers thereby contributing to a greener environment.


Link to our paper.

The project was not completed due to certain unforeseen situations. Similarly here, experience was a gain.

Link to our paper.