Skip to content

Binary-Search-1#2505

Open
mananrg wants to merge 1 commit into
super30admin:masterfrom
mananrg:master
Open

Binary-Search-1#2505
mananrg wants to merge 1 commit into
super30admin:masterfrom
mananrg:master

Conversation

@mananrg

@mananrg mananrg commented Jun 6, 2026

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Search inside a Rotated Sorted Array (problem1.py)

Strengths:

  • Clean, well-structured code with meaningful variable names
  • Correct implementation of binary search logic
  • Good use of comments explaining the approach
  • Proper handling of edge cases (returning False when not found)

Areas for Improvement:

  • Critical Issue: You solved the wrong problem. The given problem is about searching in a rotated sorted array (like [4,5,6,7,0,1,2]), not a 2D matrix.
  • The reference solution you should have implemented needs to handle the "rotation" aspect - determining which half of the array is properly sorted at each step.
  • Study the key insight: in a rotated sorted array, at least one half is always sorted. Use this property to decide which half to search.
  • Pay close attention to problem constraints and examples to ensure you're solving the correct problem.

To improve, review the rotated sorted array problem (LeetCode 33), understand how to identify which half is sorted, and adapt the binary search accordingly.

VERDICT: NEEDS_IMPROVEMENT


Search Inside a Sorted Array whose Length is unknown (problem2.py)

**

The student needs to:

  1. Read the problem statement carefully - this is NOT a rotated sorted array problem
  2. Understand the ArrayReader interface and use reader.get(i) instead of direct array indexing
  3. Implement exponential search to find the bounds when array length is unknown
  4. Then apply binary search within those bounds

The student's implementation is actually a solid solution for LeetCode #33 (Search in Rotated Sorted Array), but it's completely wrong for this problem.

**

VERDICT: NEEDS_IMPROVEMENT


Search a 2D Matrix (problem3.py)

Strengths:

  • The solution is well-structured and follows good coding practices
  • The exponential search + binary search approach is correct for the problem it addresses
  • Time and space complexity analysis is appropriate for that problem
  • Code is clean and readable with clear variable names

Areas for Improvement:

  • The solution addresses the wrong problem entirely. You submitted a solution for "Search in a Sorted Array of Unknown Size" but the assignment was "Search a 2D Matrix"
  • For the 2D matrix problem, you would need to:
    • Accept a 2D array matrix and integer target as parameters
    • Treat the 2D matrix as a flattened 1D array and apply binary search
    • Calculate row and column indices using: row = mid // n, col = mid % n
  • The reference solution shows the correct approach for this problem

VERDICT: NEEDS_IMPROVEMENT

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