Python DSA
Data structures organise values, while algorithms describe how to work with them. Choose them from the operations and input sizes your application actually needs.
Understand the idea
A linear search checks elements until it finds a match. Its worst-case work grows with the number of inputs, often written O(n). That describes growth rather than elapsed seconds on one laptop. Track memory, input constraints, and correctness alongside speed. A built-in implementation is often the right production choice.
Where to try it
Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.
A worked example
def contains(values, wanted):
for value in values:
if value == wanted:
return True
return False
print(contains([8, 3, 5], 3))
Read the result
The result is True because the second element matches.
Try one change
Count comparisons for a missing value and for one found at the beginning.