TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Data Structures Reference

287 pointsby typpoalmost 7 years ago

9 comments

kylnewalmost 7 years ago
I recently got double slammed with 2 graph questions during an interview after having navigated for years without getting a graph question. It's wholly irrelevant to my day-to-day work but I do hobby game development sometimes which involves more needs for graphing. Still, I can't do much of anything with a graph on a whiteboard. Puzzled as to why it's so important to some companies to grill on this stuff, expecting it to be top-of-mind, even for front end roles.
评论 #17430214 未加载
评论 #17430549 未加载
评论 #17428873 未加载
评论 #17428662 未加载
评论 #17429662 未加载
评论 #17429884 未加载
评论 #17430709 未加载
评论 #17429027 未加载
评论 #17428813 未加载
评论 #17429518 未加载
gameguy43almost 7 years ago
Founder of Interview Cake here. Thanks for the post!<p>Down to chat about coding interviews and answer questions here!
评论 #17428742 未加载
评论 #17429845 未加载
评论 #17428241 未加载
评论 #17429037 未加载
deckarepalmost 7 years ago
“Hashtable: like an array but instead of an index you can set arbitrary keys for each value.”<p>This sounds like a gross over simplification of what a Hashtable really is underneath the covers.<p>Any candidate that shows up with that definition better be ready to dive in on what it really is and when you’d want to use it.
评论 #17430006 未加载
A_Personalmost 7 years ago
It just amazes me that employers ask complicated CS-type questions for ordinary programming jobs. I&#x27;ve been out of the game for 20 years, and only did a few interviews anyway (as the interviewer), so what would I know! But FWIW, here&#x27;s the kind of question I&#x27;d ask.<p>&quot;I&#x27;m going to write a few lines of code on the whiteboard, tell me what you think of them.&quot; The code would be something like this:<p><pre><code> If f(a,b) then X=6 Elseif flag1 then X=8 Endif </code></pre> My bet is, people would fall into one of three camps.<p>(1) The Bemused :-)<p>These people would have no idea what to say. That would be fine for a new developer, I&#x27;d just prod them in the right direction. For example, &quot;what do you think about inline constants?&quot; But if an experienced developer had nothing to say about that code, that would be a big red flag for me.<p>(2) The Defiant!<p>These folk would say, &quot;Gee that looks like very old code, I&#x27;m really more interested in functional languages, do you guys do any Haskell?&quot; This would also be a big red flag. First, he&#x27;s saying that he has no interest in my priorities as the interviewer, he&#x27;ll just ignore my questions and substitute his own. Second, he shows that he&#x27;s <i>not</i> really interested in code <i>as such</i>. It&#x27;s like a guy who says he likes cars, you take him around the corner and show him your one-off Porsche EVO hybrid, and he says &quot;Wow, an infinity pool! What did that cost?&quot; Fail.<p>(3) What I&#x27;d Expect<p>Here&#x27;s what I&#x27;d expect from an experienced developer, off the top of his&#x2F;her head:<p>&quot;Ok, I see in-line constants, and short variable and function names. Those are often undesirable, I can talk about that more if you like.<p>But the more interesting thing, is that X is only set if one of the two conditions is true. If neither condition is true, X does not get set to anything.<p>That might be a bug: the programmer meant to initialise X before the first test, but forgot. Or perhaps X is initialised much higher up. But if that was the case, I&#x27;d like to refactor the code to bring that initialisation closer to the code on the whiteboard; and&#x2F;or rename X to something less likely to be used by mistake in the middle; or at least, add a comment saying &quot;X initialised above&quot;. Or you could just add an else branch to the code on the whiteboard, to ensure that X gets set even when both conditions are false.<p>Another slight possibility is that when the first condition is false, the second condition is necessarily true, and the developer has written in the second condition as a form of comment. But in that case, I&#x27;d rather make it more explicit, by changing &quot;Elseif flag1 then&quot;, to &quot;Else &#x2F;* flag1 must be true *&#x2F;&quot;; or even asserting that, just to be sure.<p>Also, if the code in question is really complex, or just messy from years of maintenance, there might still be cases where X does not get set at all. In that case you could initialise it to an impossible value, say NULL, right at the start, then assert not null at the end. Or you could even re-write the code in truth table style, which I can talk about more if you&#x27;d like.&quot;<p>Me: &quot;The truth table approach sounds good. How would you do that? What kind of data structures would you use?&quot;<p>And so on.<p>Does everyone really use CS-type questions these days? Does anyone take the different approach displayed above?
评论 #17430078 未加载
评论 #17429244 未加载
评论 #17429239 未加载
评论 #17429833 未加载
BerislavLopacalmost 7 years ago
Well, both types of trees mentioned in the article are just subtypes of graph, which has numerous other subtypes.<p>I love this sentence from the technical docs of the NetworkX library, for pure surrealism: A lobster is a tree that reduces to a caterpillar when pruning all leaves.
评论 #17431410 未加载
rs86almost 7 years ago
This could benefit greatly from specifying what operations are available for each structure.
emersionalmost 7 years ago
Damn. Too many javascripts on this page, including Facebook&#x27;s. I guess I&#x27;ll pass.
newscrackeralmost 7 years ago
Off topic. I really got turned off by the &quot;me@gmail.com&quot; placeholder in the signup form at the bottom of the page. So I decided not to sign up.<p>Email != Gmail. It&#x27;s one of the last decentralized systems holding up. Please don&#x27;t stick one more dagger into it.
philphilalmost 7 years ago
Good one but this is even more comprehensive: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17427190" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17427190</a>