summaryrefslogtreecommitdiff
path: root/algorithms/linear_search.py
diff options
context:
space:
mode:
authorZhongheng Liu <z.liu@outlook.com.gr>2025-02-19 09:43:52 +0200
committerZhongheng Liu <z.liu@outlook.com.gr>2025-02-19 09:43:52 +0200
commit8834da60a01294fd509c7cebf3b129fcc378d152 (patch)
treea1c6c4bd71e95780f87d35240754c5b54d3042ae /algorithms/linear_search.py
parent34bd7099d27656b4454015b0c410ca1713db5271 (diff)
downloadcs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.gz
cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.bz2
cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.zip
chore: changing to ipynb
Diffstat (limited to 'algorithms/linear_search.py')
-rw-r--r--algorithms/linear_search.py21
1 files changed, 0 insertions, 21 deletions
diff --git a/algorithms/linear_search.py b/algorithms/linear_search.py
deleted file mode 100644
index ae198d2..0000000
--- a/algorithms/linear_search.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import random
-def generate_test_data(length: int, _range: tuple):
- arr = []
- for i in range(length):
- arr.append(random.randint(_range[0], _range[1]))
- return arr
-def linsearch(myList: list, valueToFind: int):
- mindex: int = len(myList) - 1
- index: int = 0
- found = False
- while not found and index <= mindex:
- if myList[index] == valueToFind:
- found = True
- index += 1
- if found: print("VALUE FOUND!!!")
- else: print("OH NO ITEM NOT FOUND IN LIST!!")
-def main():
- inputFind = int(input("Value to find: "))
- linsearch(generate_test_data(10, (0, 1000)), inputFind)
-if __name__ == "__main__":
- main()