Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Convert binary search to iterative for improved efficiency #10552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djeada
Copy link
Contributor

@djeada djeada commented Jan 9, 2025

  • 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.

…h complexity docstring while preserving functionality
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant