Thursday, 27 March 2008

Interview Question Cont'd

Another one I was asked... was about sorting... specifically Merge Sorting.
The last time I wrote a sorting algorithm was ages ago... like in 1994 to be exact.

All those years I have been using libs (JDK, STL) to do this for me...

So for your next interview... Read Sort Algorithms to refresh your memory, and understand (ie memorise) the pseudo-code for Quick Sort and Merge Sort and their related complexity...

I am still not sure what interviewers expect you to be?
To understand things or to know things? To be able to solve problems, or just know the solutions to problems? Being able to do everything from scratch in your head, or spend time doing some research?

1 comment:

Peter Lawrey said...

Yes, I was asked how would I do a binary search or create a binary tree,
my first answer has Arrays.binarySearch and new TreeMap()
I also stated that rewriting these was a bad idea anyway.

Although the interviewer was impressed that I pointed out that
int mid = (hi + lo) /2;
was not as good as
int mid = (hi + lo) >> 1;
as the first can overflow. The second is limited by the size an array can be in any case.

Blog Archive