Skip to content

Competed Binary-Search-1#2504

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

Competed Binary-Search-1#2504
bansariradadiya01 wants to merge 1 commit into
super30admin:masterfrom
bansariradadiya01:master

Conversation

@bansariradadiya01

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Search inside a Rotated Sorted Array (search_in_sortedunknownsized.java)

  • Missing Implementation: The student has not provided any Java code solving the rotated sorted array search problem. The file only contains a comment with the filename.
  • Expected Content: The solution should implement a binary search algorithm with O(log n) time complexity, handling the rotated array by determining which half is sorted at each step.
  • Recommendation: The student needs to implement the binary search logic that:
    1. Uses two pointers (low and high) to define search space
    2. Calculates mid point and checks if it equals target
    3. Determines which half of the array is sorted
    4. Checks if target lies within the sorted half's range
    5. Adjusts search boundaries accordingly
    6. Returns -1 if target not found

VERDICT: NEEDS_IMPROVEMENT


Search Inside a Sorted Array whose Length is unknown (Rotatearray.java)

**

  1. Read the problem carefully: Make sure you understand what the problem is asking for. This problem specifically mentions the ArrayReader interface and an array of unknown size, which requires an exponential search to find the range first.

  2. Use the provided interface: The problem provides an ArrayReader interface that you must use instead of direct array access.

  3. Two-phase approach: The reference solution shows the correct approach:

    • Phase 1: Exponentially expand the search range (high *= 2) until you find a value >= target or hit the boundary
    • Phase 2: Perform standard binary search within that range
  4. Return the result: The problem expects a return value, not a print statement.

  5. Understand the constraints: The problem states you don't know the array size, so you cannot use arr.length.

**

VERDICT: NEEDS_IMPROVEMENT


Search a 2D Matrix (matrix.java)

The student has not submitted any code for this problem. To pass this evaluation, the student needs to:

  1. Implement the binary search solution for the 2D matrix search problem. The key approach is to treat the 2D matrix as a flattened 1D sorted array and apply binary search:

    • Calculate the total number of elements: m * n
    • Use binary search with low = 0 and high = m * n - 1
    • Convert mid index to row and column: row = mid / n, col = mid % n
    • Compare matrix[row][col] with target and adjust search range accordingly
  2. Follow the reference solution's approach which correctly implements O(log(m*n)) time complexity with O(1) space complexity.

  3. Ensure the code compiles and runs correctly for all test cases including edge cases like single element matrices and targets at boundaries.

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