Wednesday 10 September 2014

TCS Interview Experience

Got Placed in TCS, and here's the experience.

My TCS Experience...
Verbal ability test ---> Wrote short and simple mail on the given topic. Completed it in 6 mins and then checked it twice. Especially the spellings, and whether all the phrases are included or not..

Analytiacal Ability-----> Attempted only 16-17 questions. Took risk. But all of them were correct. There was no scope for negative marks.

It was expected that result will be declared by the night, waited till 3 for it, but it didnt.
With full confidence, reached college next day (in formals, didnt thought that what if my name will not be in the results). At 9:30, I checked the mail id, saw the the result... I was scrolling slowly, didnt used Ctrl+F.. and almost at the bottom of the list, I saw, Pallav Trivedi... and a sudden reaction.. "ab to ho jaega.."
Started preparing for interviews.. bit of DBMS, OS, DS, Java (Multithreading, exception etc).

My resume was called by the interviewer sitting in the room no. 10, but he went to take lunch and I was interviewed by the panel sitting in room no. 3
Around 3, I was called for TR..
I entered the room, two persons were sitting..
Me: May I come in sir
Interviewers: Please come in, have a seat. (I sat)

Q1. Give your resume..
Ans. Sir, I gave it to sir sitting in room no 10. as he was supposed to....(they stopped me and said no issues)

Q2. Tell us about yourself.
Ans. Good afternoon sir, I am Pallav Trivedi. I am pursuing my Bachelors of Enginnering in Computer Science. I am from Mandsaur, a city at border of Madhya Pradesh and Rajasthan. My father Mr G.P.Trivedi is lecturer in English at School of Excellence Mandsaur. I am having learning attitude because of him. My mother, Mrs Sangeeta Trived is a clerk at Women and child welfare department Mandsaur. She taught me how to manage the things. Apart from them, I have a brother, Saurabh Trivedi, he too is an engineer and serving for Bhaskar Denims, Bhopal. He got married last year, and my Bhabhi Mrs Monika Trivedi is Msc in Computer Science. As I belong to computer science fraternity, I love to do programming, but apart from it, I also keep interest in playing guitar, chess and literary stuffs.

Q3. What was your minor project.
Ans.Sir, I always had a craze to do something live, something creative. Thus, I and my room mate took the responsibility to develop the official webiste of college tech fest MTM. We did it for 2 consecutive years. First year, on java and second year on .net. As we were beginners, faced lot of problems on deploying it and learned alot. Apart from them, I made to desktop applications on Java J2EE i.e. My Word Web (Customizable Dictionary) and Packet Sniffer (a Packet Capturing application).

Q4. What is this MTM.
Ans. Sir, it is our college fest, Mech Tech Meet, organized by Mechanical Engineering Department of our college, and we were given the responsibility to develop its official website.

Q5. What programming languages do you know.
Ans. C/C++/Java

Q6. You said that you developed site on .net. You dont know .net...?
Ans. Sir, I dont know about C#. We wanted to work in a manner as industry do. So we divided teams. One of designing and other of programming. Programming part was taken by my room mate, as he knows C#, and I took designing part, HTML, Jquery, JavaScript, Photoshop etc.

Q7. Pallav, can you write a short program for me.
Ans Sure sir, which technology.

Q8. In c, write a program to find largest of three numbers. (I was so happy, as this was too much easy for me).
Ans. Sure sir, (I made the program, and used turnary operator, wherever I can)

Q9. Tell me the logic of swapping the values of two variables, without using third variable
(Again a laddu question, I answered it perfectly).

Q10. Can you write the code for swapping, using pointers.
Ans. (Damn easy for me, as pointers are my strength. I wrote).

Q11. Can you explain us, what are pointers ?
Ans. (What I wanted.. I was feeling like Super hero). Explained on paper, in a brilliant manner.

Q12. Write a program to find string length.
An    Sir which technology....  (they said C++)
                Sir, should I make separate function or in the main.... (make separate function)
                Sir, can I assume a string, or user will insert. .....(user will insert)
                Sir, how will the input come, Command Line or...    (they were smiling and asked me to leave it)
(by now, they were very happy)

Q13. How are you analytical ability.
Ans. I am weak at it sir, but I am working on it, and very soon, I'll be good at it.

Q14. How are you at innovations.
Ans. I am good at it sir, as my field of interest includes, playing guitar i.e. generating music, literature, also I chose designing field in project..

Q15. Tell us something related to your interests, poem or whatever u like.
Ans I recited a beautiful poem,
"Rahe re ubalta rakt nirantar, shira shira me aag rahe,
Sanso me sankalp ghule ho, aankho me saubhagya rahe..
Yuddh hamara, chale re nirantar, chuppi aur andhiyaro se..
Isse jyada aur kahe kya, in gum sum angaro se...!!!"

Q16. What are your dreams.
Ans. Short Term: to get selected in TCS, it has been my dream company.
          Long Term, or where I see myself after 10-15 years, I want a stable job with work-life balance, handsome salary, both of my parents living with me, a sweet heart and two little kids.
( They smiled and said, you have decided for two.. (i smiled in response).)

Q17. Any questions for us..?
Ans. I asked a question regarding Java Certification, and they answered it.
(Ok Pallav, it was nice to meet you..  thank you)

After some time, I was called for HR, it was nothing more than a formality.


Q1. Why should TCS hire you?
Ans. Mam, First of all I am good at programming, and it is a core need of TCS, as TCS provides IT Services.

Q2. Why not any other organization, all of them require programmers ?
Ans, Mam, TCS is a family. It is an institute to me, rest are organizations. From my childhood, TCS has always been with me. From Salt to Nano, Eye Plus to fast track.. every where...

Q3. Prove that you can work in team.
Ans. Mam, all the projects I made, were in team, teams were divided in a way as industry do, designers and programmers. I have been a part of volley ball team which representd the school at cluster level, and volley ball is a team game.

Q4. Tell us a quality of yours which 3 lac employees of TCS do not have..
Ans. (Though for a while )Sorry mam.... I cant say that I have any such quality which 3,05,421 employees are not having. Its such a huge number.

Q5. Ok, tell a quality which 100 students of your college are not having like you
Ans. Linguistic Capabilities.. I observed this, in speeches, debates, discussions etc.

Q6. Any Backlogs ?
Ans. For the first time in 6 semeters, I got back, it was a bolt form blue to me. I applied for reval, yesteday, the result of reval came, and it has been cleared. No backs.
(Ok pallav, all the best)




After few hours, results were announced, I was sure that my name would be there, and god didnt proved me wrong...  

Wednesday 13 August 2014

Introduction to PL/SQL.

Let us know something about PL/SQL.

Procedural Language/Structured Query Language or PL/SQL is that part of RDBMS at which we do not pay much attention while studying. However, when it comes to develop project, it is the most important part and cannot be ignored. Using PL/SQL while designing database reduces the programmer's effort exponentially. Question arises, how? And the simple answer is, 'A major portion of programming dealing with DB is finished in the database designing phase.'
Let us consider a scenario, through which we can understand the importance of using PL/SQL.

Consider an example related to accounting, in which tax on salary is to be calculated. There exists a table named employee (in which the account details are stored, say, emp_id,name and salary). Now, on using conventional programming approach, the programmer will need to make a cursor (for which, JDBC-ODBC bridge,DSN etc), through which records of employee table would be extracted, necessary calculation would be performed on extracted data and the generated result i.e. tax would be inserted back in some table say Tax. And all this will be done by programmer.
Now let us have a look at approach in which PL/SQL is involved.While designing DB, few procedures would be made(say, calculateTax and populateTax), in which necessary calculations would be done and later, simply procedures would be called. Here the point to be observed is, making procedures and implementing necessary calculations in them, calling them, all these activities are being performed at DBMS and the programmer is far away from this.

Here's the code for above example.(according to MySQL)

Now let us look at few program units of PL/SQL
  • Procedures
  • Functions
  • Triggers
First program unit is Procedure. It is similar to functions (one which we use in programming) and are used for computations, however the difference between procedure and function is
  1. Function returns a value while procedure do not.
  2. Function can be used in SQL statements while procedures cannot.
Triggers. Basically they are stored procedures which get automatically invoked on occurrence of some specific event. For example, when the values of attribute Current Balance is to be altered on the occurrence of credit/debit events, Trigger is something which would be used. A procedure (more specifically, trigger) would be wired up with insert or delete event and as soon as the events would occur, the wired up stored procedure would be triggered. 

This was a brief introduction about PL/SQL. 

Please correct me if I got something wrong.

Friday 8 August 2014

Lets have a look at Session Tracking.


Here we would be discussing about how to track session in java.
But before moving on to Session Tracking, we must know something about Servlets. Here are some key points. With the request to servlet,

·         4 Objects are made, HttpServletRequest, HttpServletResponse, Document and  PrintWriter (one of             each, at the time of request to servlet)
·         Name/Value pair, which is extracted from request is kept in object of HttpServletRequest  .
·         Specified Servlet is searched. Here story may end (if class is not found), Error message will be kept in           response.
·         Pointer of HttpServlet is taken, Object of specified servlet is made, and its address is assigned to pointer.       Again, story may end (if class do not extend HttpServlet or it is not public)
·         Now doGet(HttpServletRequest,HttpServletResponse) method is called using that pointer. For execution of doPost method, explicit call need to be placed, by default, doGet is called.

After execution of doGet, whatever kept in object of document will be sent to client( browser).

Here's an example for download (lets say one.com)
https://docs.google.com/uc?export=download&id=0B0p0u1WTbGiRV0l1ZWxmMXpSbFE

Need of Session Tracking..???

ü        Problem: Data received in first request will not be available in second response.
Solution: Session Tracking i.e. If the data in the previous request is also available in current request, then it is said that session is being tracked.

How to Track Session...???

 Here we will be discussing on the following ways of Session Tracking.

  • Hidden Form Feed
  • URL Rewriting
  • Cookies
  • Session Object

1. Hidden Form Feed: 
        Data received in first request will be sent along with the response, but in a hidden manner. For doing so, we will keep the value of type attribute as hidden in input tag.
<input type="hidden" name='XYZ' value='Previous Data'>

Here's an example of Hidden Form Feed for download. (lets say two.com)
https://docs.google.com/uc?export=download&id=0B0p0u1WTbGiRQmk4WW5TYTBnb1E

2.URL Rewriting
      To make the data available in second request, we will keep it in query string. For this, we will have to programatically generate query string. But values in query string are encoded according to Http Protocols. Thus, we will be using encode method of class URLEncoder in the java.net package.
     Lets say, 'name' is the variable which is to be encoded.
name=URLEncoder.encode(name);

Here's an example of URL Rewriting for download. (lets say three.com)
https://docs.google.com/uc?export=download&id=0B0p0u1WTbGiROXBoQXZqdkQ0WDg

3. Cookies

  • Cookie is a particular type of object, in which name/value pair is stored.
  • Cookie is made at server side, and then kept in response so as to be transferred to browser
  • Browser will store the cookie at disk, and will also keep a track that from which site, the cookie came.
  • Next time when the request will be sent to that particular site, its cookies will also be sent along with the request.
    Cookie c1=new Cookie(“name”,java.net.URLEncoder.encode(name,”utf-8”));
    c1.setMaxAge(60*10); 
    c1.setPath("/");            

     When cookie is to be given to a particular resource, setPath() will be used 
     SetMaxAge() is used to specify life span of cookie.
     
    response.addCookie(c1);

    And at receiving end,
    c=request.getCookies();
    name=c[0].getValues();

Here's an example of Session Tracking through cookies for download. (lets say four.com)

4. Session Object
      Above listed all ways of tracking session are less reliable than session object. In this way,

   ü  Data in first request will be kept in a Session Object (which will be in RAM), and the second servlet             will get it from there.
   ü  Session Object will be requested from server, which will look that whether the object exists for this               connection or not.
   ü  If not, then address of a newly created session object will be given.
   ü  Session Object will not be shared by other connections and will not be destroyed after response.
   ü  By default, Max Time Interval: 30 min
   
             HttpSession hs=request.getSession();       à requested for session object.
      HttpSession s=request.getSession(false); àReference of existing object will be given, new                                                                                         will not be created( in case it do not exists).
     
       hs.setAttribute(“name”,name);
                                  name=(String)hs.getAttribute(“name”);   à At receiving end

              Here's an example of Session Tracking through Session Object for download (lets say five.com)

       Please leave comments.!!!

Saturday 26 July 2014

In Order Traversal in Binary Search Tree without Recursion and Stack

//The code is not optimized because I wanted it to be easily understandable by  //beginners too. 

#include<stdio.h>
#include<malloc.h>
struct Node 
{
int num;
struct Node *left, *right;
};
struct Node *start=NULL;
void addNode(int num)                 //To add nodes in the tree.
{
struct Node *t,*j;
t=(struct Node *)malloc(sizeof(struct Node));
t->num=num;
t->left=NULL;
t->right=NULL;
if(start==NULL) start=t;
else
{
j=start;
while(1)
{
if(t->num<j->num)
{
if(j->left==NULL)
{
j->left=t;
break;
}
else j=j->left;
}
else
{
if(j->right==NULL)
{
j->right=t;
break;
}
else
{
j=j->right;
}
}
}
}
}

void traverseInOrder(struct Node *t)  // Function for Traversal
{
struct Node *p2;
t=start;
while(t!=NULL)
{
if(t->left==NULL)
{
printf("%d\n",t->num);
t=t->right;
}
else
{
p2=t->left;
while(p2->right!=NULL && p2->right!=t)
{
p2=p2->right;
}
if(p2->right==NULL)
{
p2->right=t;
t=t->left;
}
else
{
p2->right=NULL;
printf("%d\n",t->num);
t=t->right;
}
}
}
}

void main()
{
int ch,num;
while(1)
{
printf("\n1.Add a number \n2.In order traversal \n3.Exit\t");
scanf("%d",&ch);
if(ch==1)
{
printf("Enter a number to add: ");
scanf("%d",&num);
addNode(num);
}
if(ch==2) traverseInOrder(start);
if(ch==3) break;
}
}