title: Find a bug in Memory
body: <p>I was asked a question as below.</p>
  <p>There is a <strong>bug</strong> in memory. The bug is, described as follows:</p>
  <blockquote>
  <p>By writing at <strong>4th</strong> location, the value is updated at <strong>4th</strong> location as well as at <strong>6th</strong> location. But writing at <strong>6th</strong> location is <strong>working fine</strong>.</p>
  <p>So, when we read from <strong>6th</strong> location the overwritten value comes up.</p>
  </blockquote>
  <p><strong>How would you find this bug?</strong></p>
  <p>My approach is described below:</p>
  <ol>
  <li>Write all the location with <code>'hFF</code>.</li>
  <li>Then apply a sequence <code>read - write - read</code> (initial <code>read</code> must give <code>'hFF</code>, thereafter <code>write</code> each location with its own address and then <code>read</code> again) at each location, starting from location <code>0</code>.</li>
  <li>When we reach to <strong>6th</strong> location and during read command, we will get the <strong>corrupted</strong> value (updated by location 4) and we will find a bug.</li>
  </ol>
  <p>Is there better solution to find this bug?</p>