Skip to content

Commit d30c897

Browse files
committed
correct relative timings of search examples
1 parent 4df35e5 commit d30c897

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

episodes/optimisation-data-structures-algorithms.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,14 @@ print(f"linear_search_list: {timeit(linear_search_list, number=repeats):.2f}ms")
348348
print(f"binary_search_list: {timeit(binary_search_list, number=repeats):.2f}ms")
349349
```
350350

351-
Searching the set is fastest performing 25,000 searches in 0.04ms.
352-
This is followed by the binary search of the (sorted) list which is 145x slower, although the list has been filtered for duplicates. A list still containing duplicates would be longer, leading to a more expensive search.
353-
The linear search of the list is more than 56,600x slower than the fastest, it really shouldn't be used!
351+
Searching the set is fastest performing 25,000 searches in 0.57ms.
352+
This is followed by the binary search of the (sorted) list which is 6x slower, although the list has been filtered for duplicates. A list still containing duplicates would be longer, leading to a more expensive search.
353+
The linear search of the list is about 2700x slower than the fastest, it really shouldn't be used!
354354

355355
```output
356-
search_set: 0.04ms
357-
linear_search_list: 2264.91ms
358-
binary_search_list: 5.79ms
356+
search_set: 0.57ms
357+
linear_search_list: 1531.61ms
358+
binary_search_list: 3.43ms
359359
```
360360

361361
These results are subject to change based on the number of items and the proportion of searched items that exist within the list. However, the pattern is likely to remain the same. Linear searches should be avoided!

0 commit comments

Comments
 (0)