devops-exercises
devops-exercises copied to clipboard
Convert binary search to iterative for improved efficiency
- Converted recursive binary search to iterative for better performance and stack safety.
- Changed return type of
binary_searchtoOptional[int]for clearer type hinting. - Replaced
str.formatwith f-strings for improved readability. - Added
generate_random_listfunction to encapsulate list generation logic. - Added
find_target_in_listfunction to abstract the search process. - Introduced a
mainfunction with a docstring detailing time complexity. - Enhanced main block for better modularity and readability.
- Removed unnecessary type annotations where type is already clear.
- Maintained original functionality and interface for backward compatibility.