In my quite limited experience for university and industrial placements, questions often
are quite easy. This is because they're more interested in
how you get to the answer.
One that I was given was "Sum all numbers between two arbitrary values". If you don't put much thought into you might be tempted by:
Code:
for (int i = start; i <= end; i++) {
total += i;
}
Which is complexity
n, and not really that great. Doing a bit of research (or remembering some math), you can use a summation formula, such as:
Code:
total = (start + end)*(end - start + 1) / 2
Which is constant complexity, and much better in the majority of situations.
Point is there'll usually be a number of different answers: some better than others. It's your job to walk through your thoughts, why you dismissed certain options, and why you chose the solution you did.
Again, with the word count question there are a number of different options (good and bad) to the one you claim is easy! It's probably worth mentioning when'd you'd use libraries/frameworks in production code. While it's clearly not the approach the question wants you to take, Cocoa has a method to enumerate words that will almost certainly have a better concept of what a "word" is than what you can come up with in an interview/short test.
A couple of other questions I can remember are:
How do you switch the value of two variables without an intermediary variable? (x,y = y,x in Python, but that's cheating!)
How do you efficiently store a sparse 2D list of values?
Hope this helps.
Wow thanks so much for that! I never thought about optimizing a simple loop like that but it makes perfect sense. I could even take that division out and multiply it by 0.5 (something I do frequently in graphics code).
Sadly I cannot answer the switching variables without an intermediate question
I'd assume maybe using bitwise operators but again, without researching I honestly can't answer that :/
Even worse is I don't know what a sparse 2D list of values is
I'm assuming based of other code I've ran across (and feel free to correct me since I know I'm about to be wrong) that a sparse list would be something like numbers with large differences in values, like 1, 450, 45632, 300,000 etc. To store it efficiently I'd assume you'd use hash tables but again, I really have no clue on that one without looking something up.
I'm starting to not feel so good about myself : / (No matter I'll learn and get better).
The most recent interview I was conducting was for a DBA, and all of my questions were high-level, not asking to write queries, etc.
The most recent interview I was subjected to was not entry level, but the questions weren't all incredibly involved. One round was designing the data model for an app. Two were get-to-know-you (be able to answer what your biggest flaw is, how you'd deal with a hostile co-worker, etc.), one round was Java-specific because it's a Java shop (write a dice game implementation on the whiteboard, what does this code do, set vs. List, hashing, etc.), one round was SQL... joins, subqueries, aggregates, etc. All of this was about 5 hours one afternoon after a 1 hr phone interview with a smattering of all of that.
If you're going entry-level I don't know how technical they'll get. It depends on the interviewer. Write some code on paper. Not perfect, but good enough. Logically sound if not syntactically correct. How do you handle scarce resources like file handles? If you use the XOR trick for an in-place swap be sure to check for pointer equivalence or you'll wipe your value. Hell, you could just check for equivalence of the values.
Be ready to solve a problem you've never thought about before. Get the rules to some games and write pseudo code to solve them. Know data structures. What's a map/dictionary? What's a linked list? What's a binary tree, what's the cost to rebalance it? When is the right time to use these?
Know things about your "target" language. What's a pointer? What's pass by value? A pointer by value? By reference? By const reference? What's good and bad about these? Know constructors and destructors. Know exception handling. Know inheritance. If you don't know one of these and can't figure it out in time, be honest. I'd rather someone admit that than guess wrong.
They're going to want to see how you work and how you'll fit in as much as they want to see what you know. Be yourself. If you're fake, ingenuine, etc they'll figure it out eventually.
Good luck.
-Lee
Thank you so much for the advice!
But again, ouch. Although I could write many game pseudocode implementations (I focus on games in my programming), I could not explain what checking for equivalence in values means without googling it. I haven't ran across that in any of the roughly 8 C++ books I've gone through over the years. (I started learning it in 1998 I believe). I am also very unfamiliar with bitwise operators. I've seen them, but no books (the ones I have anyway) go into detail about how or where to use them. The closest I've gotten was "They're used for flags". Again, something else I will definitely brush up on. (I'm making quite a long list!)
As for data structures, I'm familiar with some of them, not all. I don't know what a map is but I do know dictionaries, linked lists, binary trees, and a few others are. I do not know the cost to balance one. I hope that I just skimmed over that in one of my data structures books and its in fact in there somewhere.
As for pointer, references, const references, constructors, destructors, etc, I am good with all of these, same with inheritance. I'm sure there is plenty to learn but I use these on a regular basis. One thing that caught my eye was the bad about const references. I'm sure I could think of a reason eventually but right off the top of my head I cannot.
Again, thanks so much for the advice!
Try the practice stuff at
http://codility.com/
B
This site is awesome! Thanks so much! Sadly I took the practice test and failed. Well, not really failed since I spent 10 min on it and had to leave but I didn't fully understand the question on it which is pretty bad
I'm going to try it again later when I have more time and hopefully the answer will pop in there.
Thanks so much for the advice guys, I thought I was ready for a programming job but it doesn't seem so
Even though I can generally get anything I've tried running smoothly I've been having trouble answering some of the basics thrown at me here.
No matter though, I will simply keep practicing. I practice every day but not as much as I need to, school really does get in my way. (100 hours of school work a week that isn't programming doesn't help things). Luckily I graduate in October and will have plenty of time then to not only finish an iOS game I've been working on for 3 months but also time to sit down and really analyze my programming skills, what I know and don't know and focus on what I need to.
Thank you guys again for the suggestions. It really helps me to know what to study and how to get my skills in order to get my first programming job. If anyone has any other suggestions please feel free to comment