by rcthompson · 11y ago · 0 comments
> But I wanted to appear smart, so I didn’t express any confusion.
And I don't get it. When I ask questions, if anything, I get told that I seem smarter for it. Asking questions is a sign that you're paying attention and actively trying to understand things. I don't think I've ever had anyone question my intelligence for asking questions for clarification.
(I'm not trying to criticize the OP in particular for this. I've heard it from a lot of places, and wanted to point out the fallacy.)
This goes a long way when you're talking to clients or partners too. You often need to ask questions that will appear stupid to them, but that you don't know the answer to. They normally take it that you actually care about the job/problem, and often you'll gain some important insight that you otherwise wouldn't know.
If I did get a snide response to a clarifying question in an interview, it would be an almost certain signal that I should run away from this company. Their rudeness is actually a favor, potentially sparing me months or years of unpleasantness in their company.
In fact some interviews are intended to flush out behavior like this. Give a candidate an ambiguous problem statement, and see if they ask the necessary clarifying questions.
This meta-problem (ambiguous problems/unclear goals) happens all the time in the real world and bringing clarity to situations like this is a good skill to have.
I'm asked to code a simple matrix in java. I ask about the fill factor, and get told quite low. The constructor takes the dimension and it's assumed square. I ask the interviewer if a csc matrix is ok, and he kind of says he's not sure what a csc matrix is. I tell him it's column sparse, and proceed to quickly write out, on a whiteboard, a simple csc matrix -- basically, an array of dimension columns of ArrayList of tuple <index, value>. The constructor is pretty much
ArrayList<Tuple>[] columns;
void SparseCSCMatrix(int dim){
columns = new ArrayList<Tuple>[ dim ];
}
The interviewer then starts going at me because having, eg, a million columns requires an array with a million elements in it. I say yes, duh. He says it's quite inefficient -- what if I only use 10 columns out of the million? My response is, well, that's fine -- but what you're describing isn't a matrix. It turns out that what he really wanted was a HashMap from tuple: (x idx, y idx) to value, and that a typical load would be perhaps 1k elements in a space of 1 million by 1 million.We then go at it about whether I should have asked him to clarify, and I basically decide I don't have to play along with stupid gotcha questions so I told him words have meanings and a "matrix" with only 10 non-empty columns is not a matrix. And I don't have time for wankers.
At least I learned what they were like fast...
In my experience, "matrix" is a mathematical concept, and is independent of the implementation. As such, an extremely sparse matrix, such as your alleged interviewer described, is absolutely a matrix. And for such a matrix (density 10^-9), such a dictionary-style approach seems fairly reasonable.
Next, it seems to me that "CSC matrix" is a particular encoding that works well for sparse matrices, that is not related to the code that you wrote. It contains no index/value tuples, and it consists of three top-level arrays (that, in the general case, are of different lengths).
https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_spars...
http://netlib.org/linalg/html_templates/node92.html#SECTION0...
http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/s...
Actually, it's not obvious to me how to do arithmetic on it (without converting to a denser format), though the scipy docs say it's fairly efficient, so I'm having a little think about that. Interesting.
Anyway, sounds like you're glad you didn't get that job, and I'd imagine that they're glad they didn't get you, so everybody wins.
[1, 3] = 3
[11, 3] = 17
[9936, 3] = 3
so csc makes it efficient to read down columns, ie right multiply by the transpose. My implementation makes it easier to update in the sense of inserting values at indices where previously the value was empty, since you only have to reorder a single column instead of all following data from top to bottom then left to right. Once finished inserting values, if ever, you may want to move to two packed arrays.What makes me shake my head is you don't understand what csc matrices are but didn't let that stop you from telling me I don't understand them. HN in a nutshell.
(Or even worse, there's also "I don't like your questions because my idea won't stand up to close scrutiny." I get that every once in a while too.)