hcp-uw/algo-visualizer

Edit step counter for searches

Closed this issue · 1 comments

The counter for the total and current steps includes an extra step that should be removed. Specifically, the extra step occurs upon finding the search value.
For example, given the array [3, 6, 10, 12, 14, ...], a search value of 6, and using linear search, there are currently 3 total steps which include

  1. Checking index 0
  2. Checking index 1
  3. Element found at index 1

which means that there are 3 total steps and element 1 will be highlighted yellow at step 2, then highlighted green at step 3.
Ideally, there should be 2 total steps:

  1. Checking index 0
  2. Checking index 1 and found element

where the old step 2 should be removed and element 1 should immediately be highlighted green when processed.

I would disagree with this design approach because you can't find the element in one of the slots of an array without checking it first. Better to split it apart than merge it to avoid confusion. We can reopen this if people disagree.