Code WorkOut of the Day -- Daily exercises for programmers looking for jobs, or just to keep sharp with skills and have fun.
I give talks, like this: https://youtu.be/NpvTE7GlXSM for people looking for jobs, or groups of programmers preparing for M&A tech HR due diligence.
Follow us on twitter: @codewod

How to

When solving these problems, learning by doing is much better than learning by reading. I encourage to you read only as far in the solution as you need, then trying to solve the problem. If you get stuck, try reading a little further. And of course, let me know if you find a better solution!

Thursday, February 16, 2012

Bridge Building

Problem: Discuss how you would go about building a single-tower, symmetric cable-stayed bridge. Include why you would choose this design over alternatives, and how you would build it.

Solution: This is the sort of problem that is designed to get you out of your element and a topic that you know well and see how you can approach a problem in which you have very little background.

Let's start with a picture to make sure that we understand the basics of the problem. Pic 1 shows a basic symmetric, cable-stayed bridge. If you don't know what this type of bridge is, it's good to ask your interviewer, and then draw a picture.

Well, let's take a look at pic1 and start out by describing the basics of the bridge from what we can see in the picture and what we know abut it:

1. It is a bridge (seems obvious, but don't overlook this) -- as opposed to a tunnel, ferry, etc.2. It has 1 tower3. The tower is roughly in the middle of the distance that it spans4. There are not additional supports underneath the bridge required to hold up the roadway5. The cables are symmetric6. It is slender

Well, already, this leads to part of the answer about why to choose such a bridge. At a minimum, this bridge would be advantageous when:1. You want a bridge over a tunnel or not building anything due to geographical requirements (e.g., spanning a high canyon, or cost reasons)2. For geographical or cost reasons you only want to build 1 tower and have a space where you can build a high tower3. It is possible and desirable to put the tower in the center of the distance spanned. For example, if the bridge were spanning a busy harbor, this would be a poor choice, unless there was already an island there4. It is not possible or expensive to put additional supports under the roadway (such as over navigable water)5. It is aesthetically pleasing due to its symmetry6. It has relatively little material in it (no huge superstructure etc.). This is beneficial for views, maintenance and reduced material costs

There are other advantages as well, but this is an early list and is actually pretty good.

Now, let's talk about how we would build it. This will probably lead to more potential benefits for the bridge.

Let's look at the picture and see what we would build first. Well, nothing jumps out at me, so let's think about how the bridge works and see if this gives insight.

The cables hold up individual pieces of the roadway. They both pull the individual pieces towards the tower and hold it up because they come at an angle. Therefore, the cables seem necessary before the roadway. And, the cable need to go through the tower. So, at a minimum, we need the tower first.

So, we would start building this bridge by building a major tower. Then, with our previous insight, we can run cables over the tower and slowly build out the roadway. We can then walk out on the currently built roadway and continue to build out. We could keep doing this until we got to the edges of the distance we want to build. Then, the bridge would be complete. But, do we have to do anything else?

It's worth thinking about this for completion. At a minimum, there are probably approach roads to build, signage, lighting, etc.

This is actually a pretty good answer, but it's always worth thinking about trying to go even further in an interview.

We have so far looked at the befits of this sort of bridge, but now, let's think of some of the downsides of it. Some, we have already touched on:1. It needs a tower in the middle, which may not be practical2. It must be built in a sequential order, which could make it take longer to construct than other types of bridges3. It requires a very high tower, which may not be desirable for sight views, aircraft navigation or other reasons

Let's also think about other types of bridges to contrast it with. One common type of bridge is a bridge like the Golden Gate, Verrazano Narrows, or other iconic type bridges shown in pic 2.

In these types of bridges, there are two towers. Thus, they do not require a tower in the center of the bridge. Also, the cables which support the roadway (called suspenders) do not come in at an angle, but come from above. Think of what the benefits here are. In the bridge in pic 1, the cable come an an angle.

By coming from above, the span could in theory be longer, as more of the strength of the cable is used to hold up the roadway. Hence, the type of bridge in pic 2 can span longer distances with similar strength materials.

However, look closely at pic 2, especially the edges of the bridges. You'll notice some black marks, but these are a key part of the bridge. Essentially, we need some way to hold the cables to the edges of the land. These are called anchorages. In pic 1, we do not have these as the cables essentially anchor themselves by balancing out the two pieces of roadway. This is another major advantage of the symmetric cable-stayed bridge; we do not need to build anchorages.

Well, this is a pretty good description of the benefits of a symmetric cable-stayed bridge. This is a type of problem designed to see how you approach a problem which you do not have a background in. As a general rule, it's good to draw a picture, make sure that you understand the problem, immediately state all of the seemingly obvious benefits (to make sure that you don't miss them) and then start going deeper. Try going backwards and forwards as we did in the construction element.

Then, don't stop at a 'good answer.' Interviewers love to see someone who flexes the answer. Try to go deeper when possible, as in this case with the comparison with the two tower bridge.

/*Please let me know if there are bugs or if I missed anything. Thanks, Noah */

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. Spray liner

This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work display home

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. Fourth Avenue Residences

30 minutes, once a week, free

To help the community, I do one 30 minute interview every week for free for candidates (virtual, over some online coding tools). Email me if you're interested. It's good practice for the kinds of questions you'll get, and I'll give honest feedback as to your skills, likelihood of getting a job, and tips for improving/practicing for future interviews.

I especially like to work with minority candidates, and those looking to make career changes, so please shoot me an email, provide some background, and we'll set up a time.

noah@codewod.com

Also, if you find alternative or better answers to the questions, please let me know and I'll post/credit!

About Me

About me: I'm currently the founder of Workhood (www.workhood.com) and have spent over 10 years in the technology industry. Prior to Workhood, I was the co-founder of SocialShield, acquired by Avira (A/V security company with over 100m users), where I was subsequently the VP Technology/Operations. I worked previously in McKinsey's technology practice in London and New York and also worked at several start-ups as an engineer and product manager, founding my first venture backed company when I was 22 -- and have raised over $35M in my career in financing. My focus is always on delivering great products quickly and I am a huge proponent of agile programming/product development and the lean start-up techniques. I'm a Stanford CS grad, always interested in coding problems -- co-author of the best-selling book: Programming Interviews Exposed: Secrets to Landing Your Next Job. I also went to HBS and am an avid college football and soccer fan.

I blog about coding problems at: www.codewod.com and about start-ups at www.noahkindler.com. I live in the Bay Area and can often be found at Crossfit or on the slopes when I manage to sneak out.