From 74ba42728e23cf82f3bf9bfd5b5eb41a571db660 Mon Sep 17 00:00:00 2001 From: Anusha-DeviE Date: Fri, 23 Jan 2026 00:02:13 +0530 Subject: [PATCH 1/4] Improve documentation for linear search algorithm --- searches/linear_search.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/searches/linear_search.py b/searches/linear_search.py index ba6e81d6bae4..097ce29bf0c7 100644 --- a/searches/linear_search.py +++ b/searches/linear_search.py @@ -1,4 +1,19 @@ """ +Linear Search Algorithm + +Linear search is a simple searching technique that checks each element in the collection +sequentially until the target element is found or the collection is exhausted. +It is also known as sequential search. + +Characteristics: +- Works on both sorted and unsorted collections +- Time complexity: O(n) +- Space complexity: O(1) +- Simple and reliable for small datasets + +For large datasets or sorted collections, binary search or other logarithmic search +algorithms are usually more efficient. + This is pure Python implementation of linear search algorithm For doctests run following command: From 03c60a115e28d1ef8d2239b6afc41ec43e357945 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 18:46:50 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- searches/linear_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searches/linear_search.py b/searches/linear_search.py index 097ce29bf0c7..10813652fcdb 100644 --- a/searches/linear_search.py +++ b/searches/linear_search.py @@ -2,7 +2,7 @@ Linear Search Algorithm Linear search is a simple searching technique that checks each element in the collection -sequentially until the target element is found or the collection is exhausted. +sequentially until the target element is found or the collection is exhausted. It is also known as sequential search. Characteristics: From 9d84bf4918e532affa1d9fe59be79be8e3315ef2 Mon Sep 17 00:00:00 2001 From: Anusha-DeviE Date: Fri, 23 Jan 2026 22:46:09 +0530 Subject: [PATCH 3/4] Replace asserts with explicit validation in modular_division --- maths/modular_division.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/maths/modular_division.py b/maths/modular_division.py index 94f12b3e096e..fc4bae6df3fe 100644 --- a/maths/modular_division.py +++ b/maths/modular_division.py @@ -28,9 +28,13 @@ def modular_division(a: int, b: int, n: int) -> int: 4 """ - assert n > 1 - assert a > 0 - assert greatest_common_divisor(a, n) == 1 + if n <= 1: + raise ValueError("Modulus n must be greater than 1") + if a <= 0: + raise ValueError("Divisor a must be a positive integer") + if greatest_common_divisor(a, n) != 1: + raise ValueError("a and n must be coprime (gcd(a, n) = 1)") + (_d, _t, s) = extended_gcd(n, a) # Implemented below x = (b * s) % n return x From 747da0348fada3f5572f8bb4597d8c6618180837 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 17:19:00 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/modular_division.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/modular_division.py b/maths/modular_division.py index fc4bae6df3fe..ed4ae6ae8ce3 100644 --- a/maths/modular_division.py +++ b/maths/modular_division.py @@ -34,7 +34,7 @@ def modular_division(a: int, b: int, n: int) -> int: raise ValueError("Divisor a must be a positive integer") if greatest_common_divisor(a, n) != 1: raise ValueError("a and n must be coprime (gcd(a, n) = 1)") - + (_d, _t, s) = extended_gcd(n, a) # Implemented below x = (b * s) % n return x