ManticMoo.COM -> Jeff's Articles -> Programming Articles -> C++ Interview Preparation

C++ Interview Preparation

by Jeffrey P. Bigham

Linked Lists

Questions concerning linked lists are the most-often asked questions out there. Be very comfortable with linked-lists when interviewing for any programming job. The most common questions that I've come across are the following:

  • Write code to reverse a linked list.
  • How does this change if the list is doubly-linked?
  • Write code to detect if a cycle is present in a linked-list.
  • Write code to split a linked list in the middle.
  • Read the Stanford Survey of Linked List Problems. It has answers for all of the above problems as well as an in-depth look at implementing everything to do with linked lists.

    General C++ Trivia

    I found this C++ FAQ by Bjarne Stroustrup, original creator and implementor of C++, very helpful. Interviewers will often ask you about the apparent oddities in the language and often the answers to those questions will be found here. The likelihood of you finding the exact question you'll be asked on this FAQ is pretty low, but it will get you thinking in the right way to consider the impact of these decisions and be able to reason coherently about new ones. It's an interesting read for anyone that has every wondered "Why?" about C++.

    Also, for a quick review of the C++, this C++ Primer provides a short rundown of the most popular features of C++.

    Fun Google Test: GLAT

    As part of an interesting marketing campaign that Google began in early 2004, they released the GLAT (Google Aptitude Test). It's somewhat humerous, but it has real problems on it and it's quite interesting. A scanned in version of the GLAT and the Answers.

    Some Sample "Puzzle" Questions

  • Assume you have a wick that is n feet long. Each part of the wick burns at a variable rate, but you know that the whole wick will burn in 1 hour. How do you measure 30 minutes?
  • Someone shows you 9 gold rocks. Eight of them are real and one is fake. Fake gold weighs less than real gold. The man will give you the eight real pieces of gold if you can tell him which is the fake one using only 3 measurements with a balance. How do you figure out which is which?
  • ManticMoo.COM -> Jeff's Articles -> Programming Articles -> C++ Interview Preparation