Tuesday, March 25, 2008

Pragna Technologies Interview

I think this is an IT consultant company. This is the screen interview for a Microsoft full-time/contractor software position. The interview has two part, first they send me a question documents containing three questions:

1. Given a linked list, write a function void DeleteBefore(node **head, data). For example, if the list has values 1->3->6->7->8->9->13, if data is 7, then element with data = 6 will be removed. This is fairly straightforward.

2. Given a sorted array say int num[10]={-5,1,6,7,9,9,20,25,31,45}, write a function void findsum(int [],int x) that can print out all possible pair of elements in array that can make a sum equal to x. For example if value of x is 26, then function should print {1,25}, {25,1}, {-5,31}, {31,-5}. The tricky thing is that they asked for a O(N) or O(2N) solution, and not O(N^2) solution, i.e., no nested loops. I can only come up with a O(N^2) solution, and the interviewer don't think there's O(N) or O(2N) solutions too.

3. OptimalQueues problem from topcoder


In the phone interview they basically asked me to go through the code I wrote for the first three questions, and check for any bugs. They also asked two additional questions:

4. Given 10 empty buckets and distributed 1000 coins to these 10 buckets, what's the distribution for the coins so that give any number between 1~1000, all you need to do is to return the corresponding buckets to have that number. For example, if the number is 1000, then all 10 buckets will be returned. The answer is actually quite easy but I failed at this one because I was doing it in reverse. The correct distribution is 1, 2, 4, 8, 16, 32, 64, 128, 256, 411.

5. Count the number of 1s in an integer. There's an added twist to this question as well since the integer can be negative. I gave the answer that work for unsigned int (from the programming interview exposed). To deal with negative numbers, we first check if its negative, then reverse it.

Since I don't care for contractor jobs I didn't spend much time on this. But I actually like the second part of the interview since the interviewer is very patient and actually give and explain the answers.

Tuesday, March 11, 2008

Google Calendar Sync

I've been using google calendar for nearly 2 years now, and I have to say, it's one of the best calendars out there. It's simple to use, and you can check it anytime as long as you have Internet access. But one of the bad thing is that there weren't any good solutions to sync google calendar with Outlook, which is important to me because I have a pda phone. But google has just released their own sync software and it works pretty well. And it's free! Highly recommended if you need to sync google calendar with outlook.

Link

Friday, March 7, 2008

Juniper networks phone interview

Just had a phone interview from Juniper networks. Don't think I'll get it since a lot of things I either don't know or messed up. Either way this is probably the toughest phone interview I had so far, and the kind of questions I actually expect from other companies. The interviewer first asked me if I had any other job offers, and if I need visa sponsorship, then he went right to the questions. Below are the questions I can remember, I'll try to prove the answers that I know (might not be correct!)

1. Count the number of 1s in an integer

2. Difference between little-endian and big-endian

Q1 and Q2 are in Programming Interviews Exposed


3. If uint32 *p = 100, what's the value of p after ++p
should increment by the size of the uint32 (I think)

4. What is a system call
from wikipedia, a system call is a mechanism for an application to request service from the OS.

5. Follow 4. Something about write() and strcpy()
write() is a system call

6. what does keyword volatile in C do
it tells the implementation to suppress optimization

7. Something about spinlock

8. Difference between semaphore and mutex
Since I never did any thread programming, I can't answer these two at all :-( But here are some answers.

9. difference between TCP and UDP
TCP is connection-oriented, reliable, in order delivery, and has congestion control

10. When to use TCP and UDP
TCP, when we cannot afford packet loss. UDP, time sensitive applications, voice, video etc

11. System function calls for a simple server
socket()->bind()->listen()->accept()

12. is listen() blocking?
listen() is nonblock and accept() after listen is default blocking. Note: recv() also blocks <- failed at this one

13. difference between SOCK_STREAM and SOCK_DGRAM SOCK_STREAM-> TCP, SOCK_DGRAM->UDP

14. What does the keepalive option in socket() do?
it's a heartbeat that periodically (usually 2 hrs) checks if the TCP connection is still valid.

15. can udp use connect()? what does it do?
Yes, udp can use connect(), it filters the incoming packets to certain hosts or certain port. <- not very sure A better explanation. It simply tells the OS the address of the peer. No handshake and no data is sent. Once is connected, client can use sendto() with null address, and can use send(), recv(), read(), write().

16. describe select(), what is the disadvantage of select() select monitors several sockets (file descriptors) at the same time, and let you know which one is ready so you can do further processing. disadvantage? No idea, but here are some answers

17. What is MTU/Path MTU
MTU = maximum transmission unit. The max size of a packet that the layer can handle. Path MTU, the max size of packets between a path (2 end points) can have without fragmentation. Wiki

18. describe how traceroute works
basically we sent out a series of ordinary IP packets (UDP datagram), each with increasing TTL value (1, 2, etc) and a random port. When TTL expires, the router returns a TTL expired ICMP message. When it reaches the destination, the destination returns a port unreachable ICMP message.

19. what does SOCK_SEQPACKET do?
Never seen this before, but I think I actually gave out the right answer. Here is a better explaination. Basically, it's either a sequence of packets which are delivered reliably and in order, or a reliable, ordered stream with record boundaries in it.

And there's also a question ask me to explain one of my project (id-based routing protocol). Overall I think I am ok with networking concepts, but I really need to do more study on the basic C/thread programming/socket programming stuff.

Sunday, March 2, 2008

Epic Systems Corporation Skill Assessment

-- update 5/16/11 --
Still getting a lot of comments requesting questions. Again, per agreement I am not allowed to disclose the questions. All I can say is get the book and work through it and you should be fine. I also find another book Cracking the Coding Interview: 150 Programming Questions and Solutions that is extremely useful in coding interview too. Well worth the price.

-- update 3/2/10 --
After suddenly got a lot of email about comments on this page, I've decided to update this page again. Unfortunately due to agreement with Epic, I am not allowed to disclose any information on their skill assessment to anyone. So there's no point asking me for questions. Like I said earlier, the questions are not hard and if you have worked those kinds of questions before you should be fine.


-- updated 10/28/09 --
It's been almost a year and it looks like epic is on a hiring rampage since a lot of hits is directed toward this page. To prevent epic contacting me again, all I can say is that the questions I did were very similar to Programming Interview Exposed. So get the book, read it thoroughly and practice, then I am sure you'll do well.

-- updated 12/10/08 --
Removed per Epic system's request.


Overall it's not that hard, but since they judge you on speed and accuracy (yes, you have to record the time for each question!), it's hard too say. Besides, I haven't use a pencil to write code for a long long time....