devops-exercises icon indicating copy to clipboard operation
devops-exercises copied to clipboard

Convert binary search to iterative for improved efficiency

Open djeada opened this issue 11 months ago • 0 comments

  • Converted recursive binary search to iterative for better performance and stack safety.
  • Changed return type of binary_search to Optional[int] for clearer type hinting.
  • Replaced str.format with f-strings for improved readability.
  • Added generate_random_list function to encapsulate list generation logic.
  • Added find_target_in_list function to abstract the search process.
  • Introduced a main function 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.

djeada avatar Jan 09 '25 21:01 djeada