Crypto Commerce

Practice binary search tracing on a Dell Inspiron laptop

A binary search trace answers a narrow question: after inspecting one value in a sorted list, which positions could still hold the target? Write down those surviving positions before making the next comparison. If the inspected value equals the target, the search has found it. If the candidate interval becomes empty, the target is absent from this particular list. You can practice the reasoning with pencil and paper or prepare a written trace on a Dell Inspiron laptop ; no particular application is needed for the exercise.

By Republeq Editorial · 9 min read ·
Dell Inspiron laptop: A person beside a silver laptop holds a pencil over an open notebook.

A binary search trace answers a narrow question: after inspecting one value in a sorted list, which positions could still hold the target? Write down those surviving positions before making the next comparison. If the inspected value equals the target, the search has found it. If the candidate interval becomes empty, the target is absent from this particular list. You can practice the reasoning with pencil and paper or prepare a written trace on a Dell Inspiron laptop; no particular application is needed for the exercise.


Imagine a fictional display with nine entries whose numbers are already in ascending order. Position 1 holds 12; position 2 holds 19; position 3 holds 27; position 4 holds 34; position 5 holds 42; position 6 holds 56; position 7 holds 63; position 8 holds 71; and position 9 holds 88. These are unique values. A position tells you where to look, while the number at that position is the value you compare with your target. The distinction matters: looking at position 5 means comparing the value 42, not comparing the target with the number 5.


First look for 71, which is present. Then search the same list for 55, which is absent. Using one fixed list lets you compare the two outcomes without changing the reason that positions can be excluded. The sorted order is a condition of this exercise, rather than a step to perform during the search. The trace below makes every exclusion visible so you can inspect a decision instead of trusting a final answer.


Pseudocode Tracing: Set The Interval Rules


Number the positions from 1 through 9. Call the lowest position still eligible the lower boundary and the highest eligible position the upper boundary. Both boundaries are included. Start with lower 1 and upper 9, so every entry is a candidate. While lower is no greater than upper, inspect the middle position of that inclusive interval. If there are two middle positions, choose the lower one. For example, the middle of positions 6 through 9 is position 7, not position 8.


Compare the value at the middle position with the target before changing either boundary. Equality ends the search with that position as the result. If the inspected value is smaller than the target, exclude the middle position and all positions to its left, then set lower to one position after the middle. If the inspected value is larger, exclude the middle and all positions to its right, then set upper to one position before the middle. These exclusions depend on the given ascending order: every value left of a smaller inspected value is also too small, and every value right of a larger inspected value is also too large.


A pseudocode tracing exercise needs a reason as well as a pair of new boundaries. Write the current lower and upper positions, the inspected middle position, its value, the comparison with the target, the excluded positions, and the surviving interval. On a Dell Inspiron laptop, you might type those fields into any writing surface you already use; a handwritten page works equally well. The supplied laptop listing describes a 15.6-inch display, but this method does not depend on its screen, software, or performance. Keep each row's boundaries as they were before that row's comparison so that the change can be checked afterward.


Pseudocode Tracing: Check The Middle Before Crossing It Out


At each comparison, ask whether the middle value itself is the target. A common mistake is to decide which half to keep before testing equality, especially when the target sits exactly at the inspected position. Another mistake is to keep the inspected position in the next interval even though a strict smaller-than or larger-than comparison has already ruled it out. Testing equality first separates the found outcome from the two narrowing outcomes. If the target is smaller than the inspected value, the new upper boundary is the position immediately before the middle. If it is larger, the new lower boundary is immediately after the middle.


For general practice recording the state of a procedure as it changes, see the pseudocode tracing guide. Here the important state is the candidate interval. A row is incomplete if it records a new boundary without explaining why the removed positions can no longer contain the target. That explanation is what lets another reader catch a mistaken exclusion before the final answer hides it.


Pseudocode Tracing: Locate The Present Entry


For target 71, start with the inclusive interval 1 through 9. The middle is position 5, whose value is 42. Since 42 is smaller than 71, neither position 5 nor any position to its left can contain 71 in this sorted list. Cross out positions 1 through 5. The next interval is 6 through 9. Notice that position 6 remains eligible even though it lies beside the inspected position; no comparison so far has ruled it out.


Within positions 6 through 9, choose the lower of the two middle positions: position 7. Its value is 63, again smaller than 71. Positions 6 and 7 can now be excluded. Position 6 was still a candidate after the first comparison, but the comparison with 63 supplies the later reason for excluding it. The surviving interval is 8 through 9. Recording those reasons separately shows precisely when each position stopped being possible.


The middle of positions 8 through 9 is position 8 under the lower-middle convention. Its value is 71, equal to the target, so the result is position 8. There is no need to discard position 9 or produce another interval: equality has answered the lookup question. Your trace can end with “found at position 8” and retain the last interval, 8 through 9, as the state immediately before inspection. Writing the inspected value beside the position helps prevent a tempting but incorrect conclusion that position 8 must contain the value 8.


Read the successful trace backward as a check. Position 8 survived the comparison with 42 because 71 is greater than 42. It survived the comparison with 63 for the same reason, and its own value then matched. No step discarded an unchecked candidate that might have held 71. This backward check is particularly helpful when the table of crossed-out positions looks convincing but a boundary has actually jumped too far.


Pseudocode Tracing: Show Why An Entry Is Absent


Now look for 55 in the identical list. Start again at positions 1 through 9, rather than continuing from the interval used for 71. Position 5 contains 42, which is smaller than 55, so exclude positions 1 through 5 and set lower to 6. Upper remains 9. A trace that starts at 6 through 9 without showing the comparison with 42 has the correct interval but lacks the reason for it.


The lower middle of positions 6 through 9 is position 7, with value 63. Since 63 is larger than 55, position 7 and everything to its right are too large. Set upper to 6. The remaining interval contains only position 6. At this point, saying “55 is absent” would be premature: position 6 has not yet been inspected, and its value might still equal 55. The crossed-out positions justify a narrower question, not the final answer.


Inspect position 6. Its value is 56, larger than 55, so set upper to 5, the position immediately before the middle. Lower is still 6. The interval is now written as 6 through 5; because lower exceeds upper, it contains no candidate positions. That is the absent result for this given list. The trace has accounted for position 6 as well as every position excluded earlier. You do not need to invent a special marker or inspect a position outside the interval to finish.


It helps to state what the absent conclusion covers. Under the exercise's stated values and ordering, every listed position has either been inspected or excluded by a comparison with an inspected value. The empty interval says that 55 is not one of these nine values. It does not claim anything about another display, an updated list, or an entry that was never part of the example. The scope of the conclusion is the scope of the candidate interval you traced.


Tiburn HQ Board: Diagnose A Bad Exclusion


Try a third target, 56, solely to test a faulty boundary update. Start at positions 1 through 9 and inspect position 5, whose value is 42. Since 42 is smaller than 56, the correct new lower boundary is 6. Suppose someone writes lower 7 instead. That move discards position 6 without inspecting it and without a comparison that rules it out. In fact, position 6 holds 56. The first incorrect row is already enough to explain why any later “absent” result from that trace would be unreliable.


Repair only that row: replace lower 7 with lower 6 and preserve upper 9. The next inspection then follows the stated middle rule for positions 6 through 9. Position 7 holds 63, so upper becomes 6. Inspect position 6 and find 56. The repair does not require changing the list or inventing an exception to the procedure. It restores the candidate that the comparison with 42 never excluded.


For a group discussion, you could show the written rows on a Tiburn HQ Board or any other shared surface. Its listing describes a restored 75-inch interactive display intended for collaborative spaces. Check that your intended way of displaying the trace suits the particular equipment before relying on it; this exercise assumes no connection between the board and a laptop. Ask the group which comparison justifies dropping position 6. If nobody can point to one, keep that position in the interval.


Tiburn HQ Board: Make The Boundary Decision Visible


A Tiburn HQ Board group review could keep the proposed next interval visible beside the old one, if the available setup suits that use. One person can name the middle position and its value; another can challenge the excluded range using the stated ascending order. In the 56 example, the old interval 1 through 9, inspected value 42, and proposed interval 7 through 9 reveal the gap immediately. Position 6 vanished even though a value greater than 42 could sit there. Replace the proposed interval with 6 through 9, then resume the trace from that corrected state.


Whether you write on paper or use a Dell Inspiron laptop for individual preparation, finish by checking each change against the comparison that caused it. For a found target, retain the position where equality was tested. For an absent target, show the final lower boundary greater than the upper boundary and the comparison that emptied the interval. If you want a collaborative review, inspect the linked board's listing and your display options separately; neither device is necessary for the reasoning. A sound trace leaves every removed position with a reason and every remaining position eligible until a comparison rules it out.

Practice binary search tracing on a Dell Inspiron laptop