Hacker News new | past | comments | ask | show | jobs | submit | coder007's comments login

So you prefer to use std::array over C arrays?


std::vector

What do you think std:array are?


I know, just a class version of the C-array but std::vectors has lower performance. I believe that std::array or C array are good enough for problems with non-dynamic input.


std::array is stack allocated array with known size compile time. std::vector is dynamically allocated array (on heap).

So C array equivalent = std::array, not std::vector.


The point of the parent was to write C++ code the C++ way. Most arrays in real programs should be std::vector.

Imitating C arrays with std::array is the perfect example of bastardized C/C++ code.


Using std::array is writing code C++ way. If you know size of the array compile time and you know it will fit the stack then there is no reason to use std::vector.


Here's refined list using STL if you like -

http://www.techiedelight.com/data-structures-and-algorithms-...


This graph is based on influence relation data from the now defunct Freebase, which combined various data sources including Wikipedia. Gephi was used for the graph layout, node sizing and coloring and Sigma.js is used for rendering in the browser.

For the long version, see below article that is linked via the blue info button on top right. https://exploringdata.github.io/info/programming-languages-i...


On related topic (not necessarily graph):

DFS Interview Questions - http://www.techiedelight.com/dfs-interview-questions/

BFS Interview Questions - http://www.techiedelight.com/bfs-interview-questions/


>Does anyone really ask you to write this kind of code in interviews

Whoh!! All big IT companies ask these type of questions.. but mostly to graduate students and less experienced candidates.. but some companies might ask it to a 10 year old programmer as well..


> All big IT companies ask these type of questions.

Careful with absolutes. Although I used the word "any" in my post so I guess I shouldn't talk.

Having worked at some large tech companies I can say definitely it is not "all"

Some of these examples are 90+ lines of code which is why I ask. It would not be unrealistic with that much code that candidate will be sitting in the interview room for a half hour+ coding just one question.

Several of these are borderline trick questions or only test your ability to memorize. For example, I learned Dijkstra’s algorithm in school 10+ years ago but if you were to ask me to implement it without reading the algorithm I wouldn't be able to.

Asking graph data structure questions, sure. But here are more effective ways to know if a candidate will be a good fit than asking them to implement one of these.

Use these as your interview test questions and all you are testing is the ability for the candidate to regurgitate algorithms. None of these test creative problem solving.


The thing about Dijkstra's algorithm is that it't just the obvious one that you would think of if you had never been introduced to the problem before. I'm pretty sure I "invented" it myself at least twice, and then forgot it.

Kudos to Dijkstra for nailing it down, but I think we do students a disservice by invoking his name all the time, thus making it seem scary.


>Kudos to Dijkstra for nailing it down, but I think we do students a disservice by invoking his name all the time, thus making it seem scary.

Ofc, going the other way, once they realize Djikstra's algo is simple makes every other named algo less scary

And finally they (hopefully) realize such naming is a stupid thing to be scared by and disregard it entirely


> but some companies might ask it to a 10 year old programmer as well..

I'm glad I wasn't interviewing at 10. I could program, but couldn't have handled any of these algorithms.


not saying these companies[0] wont ask these types of questions, but at least they wont ask you to answer them on a whiteboard

[0] https://github.com/poteto/hiring-without-whiteboards

related HN discussion thread[1]

[1] https://news.ycombinator.com/item?id=13874026


MIT lectures are already mentioned in the end.. and from your link, one of the tutor is same (one with pony) and the content also looks the same..


To Read the Full Story, Subscribe or Sign In. No thanks!


They have mentioned Introselect which is a hybrid of quickselect and median of medians.


Ah, missed that paragraph. Thanks.


it doesn't return the index, rather the element itself..


True. This is what I meant by confusing, without properly defining the variables at play, in this context, k is the index of the element of the ordered list, and not the kth smallest element.

Semantics, I agree, but confusing nonetheless.

Or in other words, how do we define k?


I have emailed them. post should be updated soon.


Post has been updated.


here, numbering starts from 0 same as std::nth_element


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: