I have been looking into an internship through Google, i have a good basic background, but I need more knowledge, I read C++ Primer Plus 5th Edition and got a good background from it. Where can I continue to expand my knowledge? I am trying to nail a phone interview which I may possible have coming up which requires live coding during the interview.
MasterGberry -3 Posting Whiz in Training
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
What is the general area of the internship (they could potentially ask you questions about any topic), but to direct you to something specific, it might be helpful to know. Accelerated C++ (Koenig, Moo) is a good one that will start out with some of the principles from the latter half of C++PP, and will start right into learning to use STL containers, etc. as an integral part of the text and examples. There are some specific books on templates that are supposed to be good (I haven't read them), and I'm sure people will have some other books for more specific areas.
MasterGberry -3 Posting Whiz in Training
Here were the 2 example questions they gave me (banned now obv)
1) Take a char array, and reverse the order of words in it.
2) Take a million numbers between 1-10 million and sort them.
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
These questions are designed to see if you know the right tools for the job. Of course, these two questions are extremely simple and they surely don't expect you not to be able to come up with a code that does that. What they are looking for is to see what kind of code you come up with. Since these kinds of constructs come up all the time in programming (filling an array, sorting, transformations, etc.), knowing how fast you come up with most appropriate solution is a good indicator of how productive you are as a programmer.
For these questions, obviously:
1)
void invert_cstr(const char* src, char* dst) {
std::string str(src);
std::copy(str.rbegin(),str.rend(),dst);
dst[str.size()] = '\0';
};
2)
int getRandNumber() { return rand() % 10000000; };
int main() {
srand(time(NULL));
std::vector<int> arr(1000000);
std::generate(arr.begin(),arr.end(),getRandNumber);
std::sort(arr.begin(),arr.end());
//or:
std::multiset<int> arr;
for(int i=0;i<1000000;++i) arr.insert(getRandNumber());
};
You see, the second question is a good example of a simple trick question. By asking you to sort the array, you might be tempted to start explaining some sorting algorithms you most probably learned in basic CS classes (like quicksort, mergesort, etc.) which would probably be the worst possible answer to give (it basically tells them that you'll be reinventing the wheel every day for them!). Another answer could be: "I'm gonna find an off-the-shelf library for sorting", at least they will be reassured that you wouldn't reinvent the wheel, but they still would be concerned that you are not aware that sorting algorithms are part of the standard C++ libraries (or you are not comfortable with using them.. which is worse).
Basically, people ask simple questions like this in interviews to be able to extrapolate, i.e. if you get stuck on a simple problem like that, they can extrapolate how much you will be getting stuck as you are doing the real work.
I have never passed interviews like that, so I can't really help you. I think the book that was suggested (Koenig's book) is probably good. Make sure to be very comfortable with C++ standard libraries (especially STL containers and algorithms). Modern employers are wary of the infamous "C-with-objects" problem (people who program OOP in C++ but don't take enough advantage of its powerful libraries and stick to C-style libraries, and thus, are very ineffective programmers).
Edited by mike_2000_17 because: n/a
MasterGberry -3 Posting Whiz in Training
(like quicksort, mergesort, etc.)
^ This is what one of the kids suggested but said she said no.
I wanted to use a vector container like you suggested but I was afraid then she would say "this is not time or memory efficient." She said something about using a bitmap to do that problem. At that I was completely lost.
I want to improve my usage of the STL including Vectors, dynamic memory, Maps, etc. These are the kinds of things I want to gain further knowledge of. I skipped 1 chapter in my book which discusses some of these features which I am going to go back and read (although at this point I already have learned a great deal of it on my own). I mean what pieces of the STL Should I really know?
Vectors, Maps, Strings, __________________________?
Some of these functions such as std::copy() std::remove() std::generate() I have never heard of or used...these are the kinds of things I should probably expand upon for these internship interviews. Seriously need a good place to practice these problems....
Ty for the direction so far guys :)
Edited by MasterGberry because: n/a
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
This may sound trivial, but I think that you need to be familiar with everything on this page. I mean, all the stuff on the left menu: IOStream library, String library, STL Containers, STL Algorithms and Miscellaneous. I don't mean to know all by heart of something like that. At least reading the synopsis (first page) of each of the STL containers and algorithms. This will allow you to reason about the choices for the containers and algorithms. Like saying: "I'm gonna use a std::list for this problem because the type to contain is large and expensive to copy, so it is worth the overhead of a double linked-list to gain the efficiency in insertion/deletion operations (which I anticipate to do a lot of)" or "I'm gonna use a std::map for this problem because I need fast O(logN) look-up operations and I don't have keys with the same value"... etc.
About the sorting, I think she was referring to some special linear-time sorting algorithms. If this is actually the answer that is "expected", then I guess I was wrong about the purpose of the question. This is a very theoretical answer since these algorithms are seldom used in practice (because they lack generality, so people use them only in very special circumstances). Sure, in that question, it seems the bucket-style sort would be the best, but only because it is a hypothetical situation where the numbers to be sorted are actually random and uniformly distributed (which they almost never are in real-life situations). I personally don't waste much energy studying these kinds of hypothetical problems, but computer scientists do!
That leads to the most important thing about any job interview: know exactly who is going to interview you (their names, backgrounds, positions in the company, ages, etc... how to get that info is your problem..). A lot of interview questions are designed to have multiple good answers, it is which answer you use that tells them what kind of person you are and your level of competence/knowledge. Of course, if you know what makes them tick (knowledge vs experience, practical choices vs optimal choices), then you can prepare for it by either giving the answers that you know they will like or by giving your preferred answer but justifying it well (that assumes that you can actually come up with more than one good answer). I prefer the latter because in the former, if they are clever, you can get trapped in situations where it clearly shows that you were trying to be someone you are not (and that's worse than anything else).
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.