Live data from Hacker News

Computer Science Interview Questions with C++ Solutions

grokit.ca

41–50 of 73 posts

Re: Computer Science Interview Questions with C++ Solutions

#41

I have a question, I consider myself a great software developer with a proven track record. I have open source code, lots of completed and shipped websites and software. Do interviewers really care about this sort of interview knowledge outside of the San Fransisco start up bubble? I've been programming and making a great living for more than 8 years now, and not once did I have to implement a b-list tree or somethin…

Personally, I'd walk out of an interview if they started asking me these types of questions.

Unless of course, if it's a job where it'd be very algorithm-heavy to begin with, but that isn't where my interest lies.

Re: Computer Science Interview Questions with C++ Solutions

#42

I have a question, I consider myself a great software developer with a proven track record. I have open source code, lots of completed and shipped websites and software. Do interviewers really care about this sort of interview knowledge outside of the San Fransisco start up bubble? I've been programming and making a great living for more than 8 years now, and not once did I have to implement a b-list tree or somethin…

Personally, I'd walk out of an interview if they started asking me these types of questions. Unless of course, if it's a job where it'd be very algorithm-heavy to begin with, but that isn't where my interest lies.

That's your right (of course) and I have no argument with it. But let me offer another point of view.

To my mind, the point isn't whether or not the job is algorithm-heavy. If you don't have this stuff under your belt, there are limits to what you can do. If you have to concentrate on working out which algorithm to use, or which data structure to use, if you have to spend time researching these things, that doesn't make you a poor programmer, but it stops you from spending time on the real problem solving aspects of the job.

The programmers I hire don't often have to do major algorithm stuff, and some of them are not comfortable with algorithms and data structures, but that's OK. They have other strengths.

But even if the job doesn't require deep knowledge of algorithms and data structures, knowing them helps more often than you think. One needs to know these things to recognize them when they turn up unexpectedly and in disguise. Well, in my experience anyway. Your mileage may|will vary.

But when I hire, I interview for, and care most about people's abilities to get things done, to work constructively with others, and to extend their knowledge, skills, and abilities. To walk away when someone asks about something you don't (yet) know, says that we wouldn't be a good fit anyway, and not because you don't know about algorithms.

Edited to remove some unintentional snark.

Additional edit: I don't know why you've been down-voted. Many people feel the way you do, and while I don't agree, you're entitled to your opinion, and I'm pleased you voiced it. I've up-voted you to try to offset the down-vote(s).

Re: Computer Science Interview Questions with C++ Solutions

#43

I have a question, I consider myself a great software developer with a proven track record. I have open source code, lots of completed and shipped websites and software. Do interviewers really care about this sort of interview knowledge outside of the San Fransisco start up bubble? I've been programming and making a great living for more than 8 years now, and not once did I have to implement a b-list tree or somethin…

Personally, I'd walk out of an interview if they started asking me these types of questions. Unless of course, if it's a job where it'd be very algorithm-heavy to begin with, but that isn't where my interest lies.

I don't understand this attitude. There must be lots of great companies to work at where the interview process is a bit flawed and the questions a bit unrealistic. Why let that stop you? Why handicap yourself when you can just learn it?

Re: Computer Science Interview Questions with C++ Solutions

#44
post #3

As a side note: never interview in C++. For these types of problems java is just so much easier to work with, and it's easy to learn enough java to interview with in a weekend from a C++ base. In my experience, interviewers always prefer a good easy solution (java) to a so-so difficult one (C++). Ruby and python are worth a try too, but often they make things so easy that the interviewer disregards the answer--many c…

> Ruby and python are worth a try too, but often they make things so easy that the interviewer disregards the answer--many common string manipulation interview questions are one-liners in ruby. The problem is not that they are one-liners, the problem is that the algorithm is already implemented for you as a library function, and you just call it. OTOH, in Haskell a one-liner could perfectly contain the whole descript…

I don't think that this is a deal-breaker though. In my opinion the best response you could give in this situation is: "I would use [showing you know libraries], however if this was not available I would implement it operating on characters as follows... [showing you understand algorithms]".

A good interviewer isn't going to huff because you have "foiled his master plan to trick you", since they are exploring the limits of your understanding.

Re: Computer Science Interview Questions with C++ Solutions

#45
post #2

Each question seems to come with just an uncommented code dump. Not any discussion of the actual algorithms, why it works, what the trade-offs are, etc. If I happened to ask all these questions in an interview and got all these answers, I would reject the candidate.

I have the opposite opinion. Writing comments for (in-person) interviews is silly and a sign of wasting time. Interviews in general are not designed to check your coding style, but your ability to solve problems, whether they be reasonable or not.

Your comment is a little bit along the lines of, "if you the candidate didn't use a versioning system, I wouldn't hire him". It's just not what is being tested.

Now, if it was a "here are some problems, solve them and get back to us" type of interview, then sure, I would agree with you.

Re: Computer Science Interview Questions with C++ Solutions

#46

I really wonder if this sort of rote learning has anything to do with being a decent programmer, and if sensible companies that I want to work for are really asking these sorts of questions. Personally, I could probably tell you the uses for heaps, trees, tries, and hashes before I wanted to check something in a book or look something up on the net. I would think that I am better placed to write sensible code because…

There is little use in being able to integrate functions, or to solve trigonometric equations, or to rearrange equations. However, being able to do these sorts of things without thinking too hard then releases the mind to think about other things with freedom. Similarly, effortless recall of the pros and cons of different algorithms and data-structures means that you don't have to think twice about many of the things…

I treated college math and physics as symbolic manipulation games, and graduated cum laude with majors in both subjects. I can still fly through those exercises today, a quarter century later.

My only misgiving is that the emphasis on closed form solutions, at the time, was exclusive. It distorts the choice of problems that students are given.

Not being a CSist, I don't know if a similar distortion exists in CS.

Re: Computer Science Interview Questions with C++ Solutions

#48

I have a question, I consider myself a great software developer with a proven track record. I have open source code, lots of completed and shipped websites and software. Do interviewers really care about this sort of interview knowledge outside of the San Fransisco start up bubble? I've been programming and making a great living for more than 8 years now, and not once did I have to implement a b-list tree or somethin…

I work for a well-known large tech company in the Puget Sound area. My phone and in-person interviewers asked me a balanced mix of the following:

* General questions to probe how well I knew the technologies on my resume. (What does "virtual" mean in C++? What is the difference between inner and outer joins in SQL?). Generally if I got something right they would keep probing until they got to something so esoteric i couldn't answer.

* Basic operations on fundamental data structures. (What is one way std::map could plausibly be implemented? Implement depth-first search on a tree. Implement insertion and deleting of elements in a heap.) I got stuck on deleting elements from a heap but they gave hints.

* Very simple OO design questions (would it make sense to have Employee inherit from Boss?)

* Traditional tricky algorithmics stuff (stuff where the correct answer depended on figuring out the right sorting algorithm to use, or whatever). But not TOO tricky.

* Coding problems that involved implementing some moderately complicated logic that involves thinking through a lot of edge cases (Implement the basic functionality of the wc command, write a function to convert from a string with a roman numeral to a native integer)

Re: Computer Science Interview Questions with C++ Solutions

#49
post #32

I really wonder if this sort of rote learning has anything to do with being a decent programmer, and if sensible companies that I want to work for are really asking these sorts of questions. Personally, I could probably tell you the uses for heaps, trees, tries, and hashes before I wanted to check something in a book or look something up on the net. I would think that I am better placed to write sensible code because…

I agree with Colin. I think knowing these types of things is great and studying them before an interview shows effort. I'm not sure I would ask someone to implement a B+ tree or BST or something on the spot, but knowing what one is, having worked with one before, knowing what they are useful and commonly used for is something I would definitely someone working for me to know.

I suppose I approach this from a background of Computer Science, rather than a background of Software Engineering. As such I'm interested in computation rather than "Mr Jones needs to manage his cats, etc".

If you described to me some scenario I could probably tell you I wanted a data-structure that offered constant time lookups, or that your graph was sparse and therefore I would prefer an algorithm that ran in O(E) over one that ran in O(V).

I certainly couldn't tell you the right class out of the Java Collections library.

In any case, it's holiday work.

Re: Computer Science Interview Questions with C++ Solutions

#50

Earlier quoted context omitted.

There is little use in being able to integrate functions, or to solve trigonometric equations, or to rearrange equations. However, being able to do these sorts of things without thinking too hard then releases the mind to think about other things with freedom. Similarly, effortless recall of the pros and cons of different algorithms and data-structures means that you don't have to think twice about many of the things…

I treated college math and physics as symbolic manipulation games, and graduated cum laude with majors in both subjects. I can still fly through those exercises today, a quarter century later. My only misgiving is that the emphasis on closed form solutions, at the time, was exclusive. It distorts the choice of problems that students are given. Not being a CSist, I don't know if a similar distortion exists in CS.

    > I treated college math and physics as symbolic manipulation
    > games, and graduated cum laude with majors in both subjects.
Interesting. I'm not saying this about you, but I've met several people who treated math as largely just symbol manipulation, and indeed, they ended up being great at solving the sorts of problems set, but I've sometimes had a feeling that they're sort of "barking at print". I've heard people reading perfectly well, but with no sense they they understand what they've read, despite the perfect production.

Similarly, some people can "do the math," but sometimes there's no sense of any real understanding. It's hard to explain.

This is one of the problems with interviewing. Some people can really talk the talk. They know all the words, all the phrases, can solve the problems, can produce the code for the set problems. And yet, after conversation, you start to feel that there's something just not quite right.

This is just one reason why interviewing is hard.

Post reply on HN