Activity 01
Coding Challenge: Implement Linear Search
Pairs write a linear search function in Python or JavaScript that returns the index of a target or -1 if not found. Test on lists of 10, 100, and 1000 elements, recording average search times. Discuss results and modify for worst-case scenarios.
Differentiate the conditions under which linear search is preferable to binary search.
Facilitation TipDuring the Linear Search Coding Challenge, have students print each comparison to the console so they see the sequential examination process.
What to look forPresent students with two scenarios: one describing a large, sorted list of customer IDs, and another describing a small, unsorted list of recently viewed items. Ask students to identify which search algorithm (linear or binary) would be more efficient for each scenario and briefly explain why.