From d9414d044ca0f16936d142422a3811900b832256 Mon Sep 17 00:00:00 2001 From: Benjamin Adovasio Date: Tue, 3 Mar 2026 18:07:32 -0500 Subject: [PATCH] added linear_search_print --- Project 3/project_3_search.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Project 3/project_3_search.py b/Project 3/project_3_search.py index 0931776..af063ce 100644 --- a/Project 3/project_3_search.py +++ b/Project 3/project_3_search.py @@ -12,7 +12,7 @@ from __future__ import annotations import random #to generate the 100 random values import time #for part 4, to calculae total time -#### Write your class here + class Search: """ @@ -28,7 +28,28 @@ class Search: return data + """ + This funciton preforms a search on the list for the target value, and prints the number of checks it took to find the target. + """ + def linear_search_print(self, arr, target): + checks = 0 + for value in arr: + if value == target: + print("Unsuccessful checks:", checks) + return checks + checks += 1 + print("Not found.") + return checks + + + def linear_search_count(self, arr, target): + checks = 0 + for value in arr: + checks += 1 + if value == target: + return checks + return checks