Skip to content

Binary-Search-1 #2340

New issue

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

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

Already on GitHub? Sign in to your account

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

Conversation

botlamanoj29
Copy link

Binary Search problem resolved and submitted in leet code.

@super30admin
Copy link
Owner

  1. RotatedSearch.py: The additional checks for nums[low] and nums[high] being equal to the target are unnecessary and could lead to incorrect behavior. The binary search logic should be sufficient to find the target. Remove these checks to simplify the code and avoid potential issues.

  2. Search2DMatrix.py: The implementation is incorrect. The binary search should be performed by treating the 2D matrix as a 1D array. The current logic does not correctly narrow down the search space. Review the binary search algorithm for 2D matrices and ensure the implementation correctly maps the 1D index to 2D indices.

  3. SearchInSortedUnknownSize.py: The solution is correct, but it lacks the implementation of the ArrayReader class, which is necessary for testing. Include the ArrayReader class or provide a mock implementation to ensure the solution can be tested properly.

Overall, the student has a good understanding of binary search but needs to pay more attention to edge cases and correct implementations. The code quality is good, but the solutions could be more efficient and accurate.

@super30admin
Copy link
Owner

  • Strengths:

    • The student demonstrates a good understanding of binary search concepts.
    • The code is generally well-structured and readable.
    • The time and space complexity analyses are mostly correct.
  • Areas for Improvement:

    • Remove unnecessary checks in "RotatedSearch.py" to avoid potential bugs.
    • Correct the logic in "Search2DMatrix.py" to properly implement binary search in a 2D matrix.
    • Ensure all necessary components (like ArrayReader) are included for completeness.
    • Avoid redundant print statements in the code.
    • Provide more detailed comments to explain the logic, especially for complex parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants