Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a pretty highly extensive background in development, I understand, can visualize and code from the top of my head any data structure. I understand running time complexity inside and out and can write proofs for them. I understand the space/time trade-offs in most data structures and have no problem talking about them.

But when it comes to solving a simple "algorithmic" questions in front of someone while being judged, I completely blank. I look at the question and the english words I am so used to seeing do not make any sense to me, it is a foreign language. My brain starts to think that the problems are somehow tricky and are more trickier than they truly are. I'm a mess and it isn't indicative of my actual programming skill, because behind a closed door I can easily solve these problems with some time. This has ruined a lot of my interviews and chances. I've lost all confidence.

Question: How does one improve their algorithmic thinking? Aside from reading books about it, I want to actually do it. Is there a comprehensive list of sites that provide algorithmic problems to solve?

Is this all about practice, practice, practice?

share|improve this question
1  
This sound to me like a matter of performing under interview pressure or other scrutiny. Can you solve these questions on your own, outside the 'interview' scenario? – Kirk Broadhurst Mar 21 at 16:44
@KirkBroadhurst yes I can, I solve much harder problems on my own, when I am given time to think. – Stan R. Mar 21 at 16:45
1  
in that case your question should be titled 'How to build interview confidence', and might belong on workplace.SE instead of here. – Kirk Broadhurst Mar 21 at 16:51
you might be correct. – Stan R. Mar 21 at 16:54

closed as not constructive by Kirk Broadhurst, Doc Brown, Robert Harvey, Thomas Owens Mar 21 at 18:05

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

3 Answers

Practice TDD

One of the principles of TDD is that it forces you to think about the structure of your code in ways that makes it testable. Unit testing is all about that: units of code that are individually testable.

Once you get into the mindset of thinking this way, you begin sectioning off your code into little units of functionality. Once each unit is done, you don't have to think about it anymore; you've now got this new little piece of functionality that you can combine with other little pieces of functionality into a larger program.

In addition, because you're required to write the tests first, you are forced to think about your requirements... what is this code supposed to do, and how can I organize these bits of code in a way that will help me achieve my objective?

Study other people's code

One of the best ways to learn about code structure is to study frameworks. Frameworks are all about taking a specific problem, and generalizing it into a library so that it can be applied to a wider range of problems. You can learn a ton about design by examining those frameworks.

In addition, many common problems have been formalized into software design patterns. Study those. I'm not just talking about the GOF patterns; I'm also talking about things like Object-Oriented Design, Model-View Controller, Data Access Layers, REST and the like.

Solve the Project Euler problems

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.

Write code

I could have just said this.

share|improve this answer
thanks for the answer, I don't have a problem designing large scale apps modularly or frameworks, I have a problem with being able to solve "algorithmic" questions. questions like "find the length of the longest increasing sub-sequence in log n time" – Stan R. Mar 21 at 16:49
in fact, my bread and butter is in object oriented programming and building up frameworks, but when you're on an interview nobody seems to care about that more than they care about how you're going to solve a problem in linear time. While I don't mind interviews like that I don't think they are well rounded and I always end up screwing up the algorithm parts. – Stan R. Mar 21 at 16:51
Then Project Euler is where you need to be. – Robert Harvey Mar 21 at 16:53
1  
@RobertHarvey: though your tips are fine in general, I think you miss the core point of the question. "TDD" won't help the OP for becoming less nervous at interviews. – Doc Brown Mar 21 at 17:02
1  
show 5 more comments

Your opening paragraph tells me that you're confident in your abilities around algorithms and data structures. Your second paragraph tells me that you collapse under pressure in an unfamiliar environment. As such, I think you're asking the wrong question. It's not about improving your algorithmic thinking, it's about improving your comfort level in unfamiliar, high pressure environments. Being uncomfortable and nervous clouds your thoughts. Scatters your brain. Gives you writers block. Once you pass a certain point, personal frustration starts to set in and you start beating yourself. Once you get to that point, recovery is tremendously difficult.

Unfortunately, the trick here is definitely practice, practice, practice. The best practice you can get is by signing up for as many interviews as possible (best judging, high pressure, uncomfortable situation). Try a healthy mix of highly academic employers (i.e. Google, Amazon, etc) with startups looking for generalists. From my own experience, after interviewing with Google, everything else seemed like a breeze.

Also, as I'm sure you can tell from my post, I've dealt with the same exact problem on a few occasions myself (that is, deer-in-the-headlights). After going through a bunch of interviews (I wasn't even actually actively looking for employment at the time), I can tell you that I now feel much more comfortable in stressful situations where I'm being judged.

The most important thing to remember is that the person sitting across from you is just another (guy|girl). You can engage in peer-like conversation with them. You'll also likely find that once you start having two-way conversations, your comfort level will improve.

And, for the love of whatever you believe in... Talk through the problem. Don't just sit there staring at a whiteboard or screen. And ask questions.

I know this isn't a direct answer to your question. I think you're asking the wrong question.

For practice in the actual algo parts though, take a look at sites like projecteuler, interviewstreet, checkio (if you use Python), or any number of companies that offer challenges as part of their recruitment process (Facebook, Dropbox, etc).

share|improve this answer
actually, this is what I was asking, in a convoluted way. "Once you pass a certain point, personal frustration starts to set in and you start beating yourself. Once you get to that point, recovery is tremendously difficult." -- this is exactly the point I am at. I am extremely agitated and frustrated with myself, because I know I am better than this. – Stan R. Mar 21 at 16:59
It really comes down to practice and shoving yourself in interviews as much as possible. One other way that I've found useful in becoming comfortable in interviews is by giving presentations and taking an active part in local tech meetups. Even contributing to mailing lists with people you don't know helps (at least it did for me). – Demian Brecht Mar 21 at 17:02
would you mind talking more about this to me maybe on G+ or something, I think you could really help me out. – Stan R. Mar 21 at 17:04
@StanR. - SE has chat rooms that can be created specifically for cases like this, so you don't need to rely on an external service (eg G+). Your SO rep level should allow you to create chat rooms. – GlenH7 Mar 21 at 19:32

It seems like your problem is not in understanding of how a particular algorithm works, but recognize the algorithm behind a question. Practicing algorithms only gets yourself familiar with the implementation. However, the implementation has less to do with recognizing an algorithm.

To me, recognizing algorithm belongs to a more generic thinking skill. My experience on this is nothing helps more than keeping an open mind and trying to look at things in different angle.

share|improve this answer
Obviously I don't want to practice the same algorithms over and over (say keep writing quick-sorts). I understand how these algorithms work visually and then I can code them up. My problem is when I see a new question, I freeze up and can't think of anything. – Stan R. Mar 21 at 17:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.