27.10.2014 Views

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Solutions</strong> to Chapter 12 | Testing<br />

12.5 How would you test a pen?<br />

SOLUTION<br />

pg 70<br />

This problem is largely about underst<strong>and</strong> <strong>the</strong> constraints: what exactly is <strong>the</strong> pen? You<br />

should ask a lot of questions to underst<strong>and</strong> what exactly you are trying to test. To illustrate<br />

<strong>the</strong> technique in this problem, let us guide you through a mock-conversation.<br />

<strong>Interview</strong>er: How would you test a pen?<br />

C<strong>and</strong>idate: Let me find out a bit about <strong>the</strong> pen. Who is going to use <strong>the</strong> pen?<br />

<strong>Interview</strong>er: Probably children.<br />

C<strong>and</strong>idate: Ok, that’s interesting. What will <strong>the</strong>y be doing with it? Will <strong>the</strong>y be writing, drawing,<br />

or doing something else with it?<br />

<strong>Interview</strong>er: Drawing.<br />

C<strong>and</strong>idate: Ok, great. On what? Paper? Clothing? Walls?<br />

<strong>Interview</strong>er: On clothing.<br />

C<strong>and</strong>idate: Great. What kind of tip does <strong>the</strong> pen have? Felt? Ball point? Is it intended to<br />

wash off, or is it intended to be permanent?<br />

<strong>Interview</strong>er: It’s intended to wash off.<br />

…. many questions later ...<br />

C<strong>and</strong>idate: Ok, so as I underst<strong>and</strong> it, we have a pen that is being targeted at 5—10 year olds.<br />

The pen has a felt tip <strong>and</strong> comes in red, green, blue <strong>and</strong> black. It’s intended to wash off clothing.<br />

Is that correct?<br />

…<br />

The c<strong>and</strong>idate now has a problem that is significantly different from what it initially seemed<br />

to be. Thus, <strong>the</strong> c<strong>and</strong>idate might now want to test:<br />

1. Does <strong>the</strong> pen wash off with warm water, cold water, <strong>and</strong> luke warm water?<br />

2. Does <strong>the</strong> pen wash off after staying on <strong>the</strong> clothing for several weeks? What happens if<br />

you wash <strong>the</strong> clothing while <strong>the</strong> pen is still wet?<br />

3. Is <strong>the</strong> pen safe (e.g.—non-toxic) for children?<br />

<strong>and</strong> so on...<br />

2 1 3<br />

<strong>Cracking</strong> <strong>the</strong> <strong>Coding</strong> <strong>Interview</strong> | Concepts <strong>and</strong> Algorithms

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!