Live data from Hacker News

Computer Science Interview Questions with C++ Solutions

grokit.ca

61–70 of 73 posts

Re: Computer Science Interview Questions with C++ Solutions

#61
20 year veteran here (although experience does not really equal the 'years in business', it is a multiple of years in business and ability to 'accumulate' and 'apply' the experience).

Interview is a negatives filter, not a 'successful employee' indicator.

As a filter, it should be adjusted depending on the job markets, salary/benefit brackets and the type of effort a company/team is willing to put into a hire.

A retained hire is a hire who passed the negative filter and then passed the 'successful hire' assessment, which should be done in a 3 month period.

A company that is not willing to let a bad hire go after 3 month assessment, will eventually accumulate a horrible baggage, that will bring their productivity and morale.

No interview (negative filter) can be good enough to avoid the 3 month assessment. If you do not accept this thinking, and still assume that you can construct an interview that will be good enough to avoid the 3 month assessment -- then you are a likely looking to hire candidates that mimic you, and in general (regardless how average/special you are) -- you will hard time finding the candidates, and actually scaling up your hiring effort.

Back the actual interview.

Programmers need to know which algorithms are sensitive to data sets and in which way (memory consumption, disk consumption, run time cost)

Programmers need to be able to find good implementations for the specified constrained. this is important -- they need to be able to find the existing solutions, not build them themselves (unless you are hiring researches to work out things that have not been done before).

So a good test would be to present a problem, and ask a candidate to do a quick internent research, and find analogies/approaches for a given problem. Asses which one of the found on the net solutions fit better to the problem space. And then describe how they would incorporate what they have found into an implementation, and how much effort they think it should take.

Programmers need to be able to reason about maintainability and testability of the code base, using both previous experience, and analogies from open source projects. Having references to popular books on this topic is helpful is well. This is largely non-formal topic based on empirical evidence or personal experiences. So they do not need to match interviewer's expectations, but must be well argued.

Programmers need to be able to articulate how they react to business decisions that require weighting various trade offs.

Finally, important to see how they relate to the team members that they worked with, from the company they are coming from.

The interview questions posted by the OP address not more than 10% of the criteria I outlined above, so in my view these are poor examples of the CS interview questions.

Re: Computer Science Interview Questions with C++ Solutions

#62

Earlier quoted context omitted.

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 r…

Well, I certainly can't plead innocent. ;-)

I've realized for a long time that what's gotten me through school and life is a series of accommodations for the brain that I happen to possess.

Oddly enough, things "clicked" for me in terms of developing the deep understanding underlying the symbols, but not always concurrently with whatever course I was taking.

Re: Computer Science Interview Questions with C++ Solutions

#63

I'm surprised, in an industry that is founded upon automating repetitive tasks, that the coding interview can't be automated. Isn't that what standardized testing is all about?

This comment nails it: > I really don't find these questions to be useful indicators > of the things that make-up a good software engineer. I am > using "software engineer" here on purpose and as something > distinct from "programmer" or "coder". > One will design and develop good reliable products that are > maintainable and extensible. The other will just crank out > code and is likely to not really add value beyon…

Very good point, and I realize that I was being a bit sarcastic about standardized testing. In fact it's possible that if a particular set of coding questions gains widespread use, then it will function as a de facto standardized test, with the result that you predict. This could already be the case if both employers and applicants are searching online for lists of the best interview questions.

Re: Computer Science Interview Questions with C++ Solutions

#64
post #58
post #56

Earlier quoted context omitted.

You get the job if you can think of a non-trivial way in which in matters.

That's pretty easy. Pre-C89 did not have void pointers, thus a generic linked list would have to use char pointers. Beyond the wrong-ness of using an incorrect dereferencer type you would also force any users of your linked list to make an explicit cast. Meanwhile a post-C89 linked list could return void *. Thus taking advantage of C's implicit cast of void pointers. Meanwhile if you compiled this second void pointer…

K&R (V7) cc happily handles implicit casts of char* ; void* is just char* with a new name and a pair of handcuffs. If you're writing a linked list, though, you'd be using a 'struct listnode *next' in any dialect.

Re: Computer Science Interview Questions with C++ Solutions

#65

I'm surprised, in an industry that is founded upon automating repetitive tasks, that the coding interview can't be automated. Isn't that what standardized testing is all about?

This comment nails it: > I really don't find these questions to be useful indicators > of the things that make-up a good software engineer. I am > using "software engineer" here on purpose and as something > distinct from "programmer" or "coder". > One will design and develop good reliable products that are > maintainable and extensible. The other will just crank out > code and is likely to not really add value beyon…

Standardized testing will quickly get subverted, with people "studying for the test." It's almost a theorem that any proxy for assessment will become subverted, with people passing the test without actually possessing the necessary underlying skill. In math people keep complaining about "teaching to the test" and that people pass the tests, and yet don't have the skills.

Same will happen if you try to standardize computer recruitment.

Hasn't the industry effectively done that already? Doesn't the fact that almost anyone of reasonable ability[1] can pass an interview after studying something like Cracking the Code Interview indicate that you can successfully "study for the test"?

[1] I am assuming that, even when "teaching to the test", a certain amount of baseline ability is still required to actually pass.

Re: Computer Science Interview Questions with C++ Solutions

#66
post #58
post #56

Earlier quoted context omitted.

You get the job if you can think of a non-trivial way in which in matters.

That's pretty easy. Pre-C89 did not have void pointers, thus a generic linked list would have to use char pointers. Beyond the wrong-ness of using an incorrect dereferencer type you would also force any users of your linked list to make an explicit cast. Meanwhile a post-C89 linked list could return void *. Thus taking advantage of C's implicit cast of void pointers. Meanwhile if you compiled this second void pointer…

Sorry I should have explained myself better:

I am referring to the C-standards, and I don't consider K&R to be one of them. I tried compiling the source with:

  gcc file -std=c89 -Wall -o out
&&

  gcc file -std=c99 -Wall -o out
I get a score of errors thrown at me.

Not one of them mentioned a void* or char, they don't appear in the code. The float which holds the data is located within the struct itself.

The first nine errors were all practically identical:

  error: unknown type name 'LL_Element'
I don't know much c99, but when it comes to c89 whenever an instance of a struct some_type* is declared the keyword struct also has to precede the type: ie. struct some_type some_instance;. The only way I am aware of that overcomes this is the use of typedef in the original declaration.

I'll have to check whether it is mentioned in the 1988 edition of The C programming language or another text, but if I recall correctly the term tag is used to refer to struct declarations.

Also the original code had the headers && . I think these headers have all their functions declared as inline, a non-existent keyword with regards to c89. I had to change the headers to the traditional .h style header in order to have a chance of getting the code to fit through the slot, so to speak.

I don't have a CS degree, I teach myself, so if I have missed something or made a faux pas, please say so.

Re: Computer Science Interview Questions with C++ Solutions

#67

Earlier quoted context omitted.

This comment nails it: > I really don't find these questions to be useful indicators > of the things that make-up a good software engineer. I am > using "software engineer" here on purpose and as something > distinct from "programmer" or "coder". > One will design and develop good reliable products that are > maintainable and extensible. The other will just crank out > code and is likely to not really add value beyon…

Standardized testing will quickly get subverted, with people "studying for the test." It's almost a theorem that any proxy for assessment will become subverted, with people passing the test without actually possessing the necessary underlying skill. In math people keep complaining about "teaching to the test" and that people pass the tests, and yet don't have the skills. Same will happen if you try to standardize com…

Here's my observation about "teaching to the test," having two kids who are now in middle school. Since every kid has to pass, the test is written to the lowest common denominator. Drilling the test over and over, to boost the school's average by a few points, short-changes the kids who have already mastered the material and need more challenge.

Something like "cracking the code interview" could become an upper bound.

Re: Computer Science Interview Questions with C++ Solutions

#68
How much does one need to understand how a car's engine works to drive a car?

I believe there is some relevance to a deep understanding of algorithms, that relevance being a function of the job. But in situations where the relevance is CLEARLY low for the job, they serve as nothing more than projections of the egos of CS grads, and reduce the value of their company.

Re: Computer Science Interview Questions with C++ Solutions

#69

Earlier quoted context omitted.

> 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 lim…

If you cannot use libraries in a typical dynamic language, stuff is almost always just as inconvenient as in Java or C++.

Re: Computer Science Interview Questions with C++ Solutions

#70
post #38
post #13

Earlier quoted context omitted.

I always tell candidates "I am multi-lingual, feel free to answer in any language you want, with bonus points for Lisp or Scheme." So far no one has taken me up on the latter option. :( Everyone ends up coding in straight C, rather annoying really. I'd kill for someone to pull out Python or some other language more suited to the problem. All that said, straight Java is also likely a horrible choice. Boilerplate code…

> So far no one has taken me up on the latter option. :( That's weird. I always thought Clojure would be great for these kind of questions if allowed. I guess Clojurians are scarce. Oh, and it's real fun too! http://www.4clojure.org has lots of riddles to solve.

I don't know Clojure, too much time in the MS ecosystem, I don't even have a JVM installed anymore. (I got tired of the constant security holes and updates that try to bundled software.)
Post reply on HN