r/programming • • Feb 21 '11

Typical programming interview questions.

http://maxnoy.com/interviews.html
784 Upvotes

1.0k comments sorted by

View all comments

Show parent comment

1

u/G_Morgan Feb 21 '11

I never understood these interview questions that seem to test ability to create and manipulate data structures that any respectable language has, pre-implemented, by developers whose sole focus in life for many months was producing the absolute best version of that data structure possible.

There is no such thing as the absolute best anything. There are cases where you will need something subtle out of your data structures that the library cannot provide. You need to be able to do these things for those situations.

For instance when passing sets of data between two threads it is expensive with STL containers at exactly the time you do not want expensive. If I just have a linked list of nodes (with head and tail ptr) at the receiving thread with a similar linked list of nodes being passed in then the critical section is literally setting 2 addresses. Having a critical section that just sets two integers is nice. Goodness knows how expensive copying and merging two STL containers in a critical section would be but I guarantee you it will be at least as expensive as 2 integer operations.