Sunday, May 15, 2005

A bit of Interview Prep

Just a little from here and there of some things I am learning for an upcoming interview... may be useful...(i may continously modify this)

Networks

ISO OSI Protocol stack

Application
Here user applications access file (database), print, messaging (email), and other services plus support error recovery.


Presentation
# Network redirector makes remote printers appear attached
# character set (ASCII - EBCDIC) conversion
# interpretation of graphics commands
# data encryption (scrambling and descrambling the data as it is transmitted and received).
# data compression (into zip format)


Session
# name-to-station address translation,
# security authentication,
# connection ID establishment,
# data transfer (using session),
# acknowledgements, and
# connection release.


Transport
# ensures data is delivered error-free by dividing and combining message segments in sequences;
# resolving logical address/names by starting sessions of TCP or UDP services used for establishing end-to-end connection between Transport Layer peer computers.
# sends acknowledgement for data packets received;
# manages error and flow control.
Multicasting?


Network
#Handles logical addressing and translates logical names into physical addresses.
#Encapsulates packets into datagrams (small network-transportable packets) using routing algorithms.
#Concerned with routing -- addressing and looking for the best path on which to send information.
#Prioritizes data and other Quality of Service (QoS) functions.


Datalink
# Organizes raw data into a logical structure of frames (addressable units of information) thru NIC's fed by Switches and Bridges.
#Concerned with physical (as opposed to network logical) addressing, network topology, line discipline (how end systems will use the network link)
#Data transmission synchronization: ordered delivery (sequencing) of frames,
#Flow control: waits for a positive ACK.
#Performs error notification.


Physical
#Establishes, maintains, and terminates point-to-point data links.
#Signal Encoding: Puts raw data bits on the wire and pulls them off the transmission medium.
#Cables, Connectors, Terminators, Transeivers, Repeaters, Passive Hubs, Active Hubs, Switches send data to specific lines
#Controls the transmission technique, pin layout, and connector type.
#Concerned with voltage levels, data rates, timing of voltage changes.
#Cabling




Answers to some common questions:



Difference betweenSocket and Port?
A port is a service provided by a machine. That service is identified by a number.
A socket is the way a server and a client keep track of requests. Each request gets a different socket.
Ports are a broad reference to a type of service, whereas a socket refers to a specific connection on a specific port.
Ports and Sockets are both typically represented as integers. Both can take a value from 0 to 64K-1
A socket is defined to be the unique identification to or from which information is transmitted in the network. The socket is specified as a 32
bit number with even sockets identifying receiving sockets and odd socket identifying sending sockets.
A port number represents an endpoint or "channel" for network communications. Port numbers allow different applications on the same computer to utilize
network resources without interfering with each other.

Database:

DBMS:A DBMS is a collection of interrelated data and a set of programs to access those data

Physical Schema: Database Design at the Physical level(how data is stored on disk, etc)

Logical Schema: Database Design at Logical level(what data?relationships between data, etc)

Job of Database Administrator? He is responsible for shema, authorisation, maintenance(backup, upgradations, free up space, etc)

Superkey: A set of one or more attributes that taken collectively allow us to uniquely identify an entity

A superkey of which no proper subset is also a superkey is called a candidate key.

Primary key is the candidate key chosen by the database designer

The candidate key that is not selected as a primary key is called aggregate key

no primary key? =>weak entity set

Normal Forms:

1st:If the domains of all attributes of R are atomic.

BCNF:If for all functional dependencies a->b either a->b is trivial(ie bis a subset of a) or a is the superkey

3rd:If for all functional dependencies a->b either a->b is trivial(ie bis a subset of a) or a is a superkey or each attribute in b-a is contained in a candidate key for R

4rth:If for all multivalued dependencies a->>b, a->>b is trivial, or a is a superkey of R

Answers to some common questions:


Difference between "ORACLE" and "MICROSOFT ACCESS" databases?
* Oracle can handle thousands of concurrent users; Access about 40-50
* Oracle's locking structure is years ahead of Access. The database will not
lock up as easily as Access when people update data.
* Oracle has online backups and better export capabilities
* Oracle can recover a database to a point-in-time ; Access cannot.
* Oracle8 has things like bit-mapped indexes, reverse-key indexes, table and
index statistics, partitioned tables, advanced security (password management),
multi-threaded server, and replication, to name a few.

What is the difference among "dropping a table", "truncating a table" and "deleting all records" from a table.
Dropping : (Table structure + Data are deleted), Invalidates the dependent objects ,Drops the indexes
Truncating: (Data alone deleted), Performs an automatic commit, Faster than delete
Delete : (Data alone deleted), Doesn’t perform automatic commit

How will you copy the structure of a table without copying the data?
CREATE TABLE newTable AS
SELECT *
FROM oldTable
WHERE 1= 2;


C++

Virtual functions:
C++ virtual function is,

* A member function of a class
* Declared with virtual keyword
* Usually has a different functionality in the derived class
* A function call is resolved at run-time

The difference between a non-virtual c++ member function and a virtual member function is, the non-virtual member functions are resolved at compile time. This mechanism is called static binding. Where as the c++ virtual member functions are resolved during run-time. This mechanism is known as dynamic binding.
class Window // Base class for C++ virtual function example
{
public:
virtual void Create() // virtual function for C++ virtual function example
{
//print "Base class Window"
}
};

class CommandButton : public Window
{
public:
void Create()
{
//print "Derived class Command Button - Overridden C++ virtual function"
}
};

void main()
{
Window *x, *y;

x = new Window();
x->Create();

y = new CommandButton();
y->Create();
}

The output of the above program will be,
Base class Window
Derived class Command Button

If the function had not been declared virtual, then the base class function would have been called all the times. Because, the function address would have been statically bound during compile time. But now, as the function is declared virtual it is a candidate for run-time linking and the derived class function is being invoked.

Friend functions:

A class can allow non-member functions and other classes to access its own private data, by making them as friends. This part of C++ tutorial essentially gives two important points.

* Once a non-member function is declared as a friend, it can access the private data of the class
* similarly when a class is declared as a friend, the friend class can have access to the private data of the class which made this a friend

Inheritance:
Some of the exceptions to be noted in C++ inheritance are as follows.

* The constructor and destructor of a base class are not inherited
* the assignment operator is not inherited
* the friend functions and friend classes of the base class are also not inherited.

There are some points to be remembered about C++ inheritance. The protected and public variables or members of the base class are all accessible in the derived class. But a private member variable not accessible by a derived class.

It is a well known fact that the private and protected members are not accessible outside the class. But a derived class is given access to protected members of the base class.
The order of execution of destructor in an inherited class during a clean up is like this.
1. Derived class destructor
2. Base class destructor
Use virtual destructor in derived class else wont work.

Copy constructor:
Copy constructor is

* a constructor function with the same name as the class
* used to make deep copy of objects.

There are 3 important places where a copy constructor is called.

1. When an object is created from another object of the same type
2. When an object is passed by value as a parameter to a function
3. When an object is returned from a function

If a copy constructor is not defined in a class, the compiler itself defines one.

Operator overloading:
//C++ overloading sample
class MyString
{
public:
char member1[100];
void operator +(MyString val)
{
strcat(member1, val.member1);
}
};



JAVA



Answers to some common questions:


What modifiers are allowed for methods in an Interface?
Only public and abstract modifiers are allowed for methods in interfaces.

Can an Interface have an inner class?
Yes

What are wrapped classes?
Wrapped classes are classes that allow primitive types to be accessed as objects.

What is the finalize method do?
Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.

What is mutable object and immutable object?
If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …)

Which package is always imported by default?
The java.lang package is always imported by default.

Puzzles

Suppose you are in a hallway lined with 100 closed lockers. You begin by opening all 100 lockers. Next, you close every second locker. Then you go to every third locker and close it if it is open or open it if it is closed (call this toggling the locker). Continue toggling every nth locker on pass number n. After your hundredth pass of the hallway, in which you toggle only locker number 100, how many lockers are open?
(The correct answer is 10)

Bear Hunting
"A man is out hunting. He walks one mile south. He makes a ninety degree turn to his left. He walks another mile. He makes another ninety degree turn to his left and walks another mile. He is now back where he first started. He shoots a bear. What color is the bear?"

Spinning Wheel
"A wheel is painted half black and half white. You can place two stationary sensors anywhere on the surface of the wheel. The sensors tell you what color they see. How can you tell which way the wheel is spinning? And how long does it take before you know?"

A Pirate as Emissary
"There are two kings, each on an island. Each king has one valuable diamond, one box, one lock, and one key. The king on the first island has a daughter (so we'll call him the Daughter King). The king on the second island has a son (so we'll call him the Son King).
"The only way between the islands is a pirate ship. The pirate is open to doing a bit of commerce, but he's a pirate. If he can get the diamond and keep it, he will. The kings, on the other hand, are honest, which is to say that they don't steal and they keep their word.
"The kings are trying to arrange a marriage between their respective offspring. The diamond is what proves how great a king is. The Son King has demanded to see the diamond belonging to the Daughter King. The Daughter King is willing to show it to him. How can he show off his diamond (and get it back) without any possibility of its being stolen? "

You have 2 candles. Every candle lights for 60 minutes. You have to find the way to measure 45 minutes.

A snail wants to creep on to the top of the tree 5 m high.During the day it can creep up 3m but during the night it creeps down 2m. How many days does it need to reach the top?

There are 3 switches in one room that control 3 electrical lamps located in the other room.You are allowed to spend 5 minutes in the room with switches,change their position as you want.Then you should go to the room with lamps and tell exactly what switch controls every lamp.You can't return to the room with switches.

There is a pot full of water. How to pour out half of it without using a meter?

9 coins,one of them is fake. Use a balance to weigh them not more than 3 times and find the fake.A fake coin is not necessarily lighter.

Connect 9 dots with 4 lines . Don't cross the same dot twice.

A point is chosen at random from within a circular region.What is the probability that the point is closer to the center of the region than it is to the boundary of the region.

Why are manhole covers round ?


Parachutist is landing the island in the darkness. The island is of unknown shape. There must be a fenced lot at the island. The parachutist needs to find out if he is within the fenced lot or outside.

If you ask electronics engineer " To be or not to be ?" , his answer will be "One!" How come?

A band is going in the street with a constant speed.Someone in the last raw has a dog.The dog runs ahead, reaches the front line of the band and gets back to it's owner. The dog's speed was also constant all the way and while it was running the band passed 50 feet. Find the length of the dog's path,if the distance between the front and the rear line of the band is 50 feet.

You are playing a game with your partner.The idea is to cover a round table with quaters. The one who puts the last coin - wins.Suggest a winning strategy.

There are 100 gold coins in 10 columns by 10 coins in each column. Every coin weights 1 lb. One column contains 10 fake coins.Each coin in it weights 0.9 lb. Take one measurement to find the column with fakes.

Two drivers are going to the next town which is 100 miles away. They depart at the same time, however the first driver stops for gas during the first 50 miles, the second driver stops during the second half. Each stop takes 10 minutes. They both drive with the same speed 60 mph during the first 50 miles and 65 mph during the second half. Who, do you think, arrives first?

A chess board has 64 squares.Two squares in the diagonal corners are masked out.Is it possible to cover the rest 62 squares with 31 dominos? (One domino covers two squares.) Explain the logic of your answer.

How to cut a plain circular cake for 8 people with just three straight cuts of knife?

There are four numbers: 1, 2, 5, 10 that you have to carry in a boat across a river. Every time you may not carry more than two numbers , and the time of traveling is associated with the largest of two numbers. One number has to be in the boat during the return journey, which also defines the time for this trip. What is the minimum total time to carry all numbers from one bank to another?

A man went down to the river with two jugs, one of three-liter capacity and one of five-liter capacity. Using just these , how did he bring back exactly four liters?

You drove to the next town with a speed of 60 miles/hour. On your way back the speed was 40 miles/hour. The distance is 120 miles. Calculate the average speed.

A man is running across a bridge.When he is 3/8 of the way accross, he heard a train coming behind him. If he keeps running he will reach the end of the bridge at the same time with the train. If he turns around and runs back, he will get to the beginning of the bridge at the same time with the train. The man runs at a speed of 5mph. What is the speed of the train?

We are going to play a paper-rock game (similar to paper-rock-scissors). If we both have "paper" - I pay you $3, if we both have "rock" - I pay you $1. If they don't match - you pay me $2. Suggest a winning strategy?

You are sitting in a boat in the middle of a lake. You pick up a rock from the boat and throw it into the lake. Did your action raise or lower the water level at the edge of the lake?

If you are in a dark room with a candle, a wood stove and a gas lamp. You only have one match, so what do you light first?

Would you rather a crocodile attack you or an alligator?

A customer at a 7-11 store selected four items to buy, and was told that the cost was $7.11. He was curious that the cost was the same as the store name, so he enquired as to how the figure was derived. The clerk said that he had simply multiplied the prices of the four individual items. The customer protested that the four prices should have been ADDED, not MULTIPLIED. The clerk said that that was OK with him, but, the result was still the same: exactly $7.11. What were the four prices?

A rich aristocrat decided that he would give every man $45 and every woman $60. Only one ninth of the men and only one twelfth of the women collected their dues. Can you tell me how much money the aristocrat spent if there were 3552 people in total?

The local river Trent is 4100 inches wide, which happens to be a fantastic number. There is a magnificent bridge which spans the river. During a recent survey of the area it was found that one seventh of the overall length of the bridge was on one side of the river and one eighth of the bridge was on the other side of the river. How long is the bridge which spans the river Trent?

After visiting my Great Aunt Anne, I travelled home in my old jalopy. The car was so old and battered, I was stuck in second gear. This meant that I could only travel along at a steady 30 miles per hour and managed a paltry 20 miles per gallon of fuel. At the start of the journey I had placed exactly 10 gallons of fuel into the tank. I knew though, that the fuel tank lost fuel at the rate of half a gallon per hour. As I arrived home, the car stopped because it had run out of fuel and I only just made it. How far was it from my Great Aunt's to my home?

A large fresh water reservoir has two types of drainage system. Small pipes and large pipes. 6 large pipes, on their own, can drain the reservoir in 12 hours. 6 small pipes, on their own, can drain the reservoir in 18 hours. How long will 6 large pipes and 6 small pipes take to drain the reservoir?

Add a single straight line to make this equation true - the equals sign remains untouched.
5 + 5 + 5 = 550

One family wants to get through a tunnel. Dad can make it in 1 minute, mama in 2 minutes, son in 4 and daughter in 5 minutes. Unfortunately, through the tight tunnel can go at once not more than two persons moving at the speed of the slower one.Can they all make it if they have a torch that lasts only 12 minutes and they are afraid of the dark?

A farmer is returning from market, where he bought a she-goat, a wolf and cabbage. On the way home he must cross a river. His boat is little, allowing to take on it only one of the three things. There can't stay together the she-goat and the cabbage (because the she-goat would eat it), neither the she-goat with the wolf (because she-goat would be bitten .How will the farmer get everything on the other side (without any harm)?

Monday, May 09, 2005

CTS beckons

The day I got the CTS offer letter, something inside me said, "Akhil, you're settled for now. Be satisfied and relax your way to the end of college life." I wonder what prompted that reaction in me. Everyone around hurled towards me warnings like "Your potential wont be tapped", "Ur gonna be bored to death", and "Ur kidding, right?". But for some very strange reason, I did not seem to care. Somehow, I have been filled with this extremely positive spirit that CTS is where im gonna make a difference, where im gonna succeed. Whatever.

A couple of other interviews have come and gone. I didnt really expect to get selected, given my preparation, or lack of it. I have emerged wiser though, and more knowledgable. But for each of these interviews, I always wondered if CTS would be a better bet. Some complex set of relations in my head that i just cannot understand always seemed to favour CTS. And this is in comparison with MNC's like Microsoft. I mean, HOW CRAZY AM I? Go figure.

There are probably gonna be one or two more placement opportunities that'll come my way. However, ever since CTS picked me up and threw me into its, so painfully overpopulated ocean, I've only considered these oppurtunities as possible motivations to learn something new. To enrich my knowledge. Nothing more. That is, of course, till the day of the interview finally arrives, and one cannot avoid getting carried away by the hype generated.

Many questions have come to mind. "If I had gotten rid of this "Im settled" flu and prepared hard before hand for these interviews, would I have been better off?". "Would it have been better if I had concentrated on CGPA, built up my academics, and sacrificed my extracurriculars?". I have concluded that my answer to these questions is gonna be a simple and straightforward NO. College life comes only once (sometimes twice), and I would not sacrifice one second of the time spent playing cricket, having fun with friends, participating in culturals, and doing practically nothing (a very enjoyable passtime) for a job in Microsoft or the like. Yea, I know. Im nuts. Force of habit, I guess.