Skip to content

Binary Search1#2496

Open
YogeshPardeshi wants to merge 2 commits into
super30admin:masterfrom
YogeshPardeshi:master
Open

Binary Search1#2496
YogeshPardeshi wants to merge 2 commits into
super30admin:masterfrom
YogeshPardeshi:master

Conversation

@YogeshPardeshi
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Search inside a Rotated Sorted Array (.idea/Binary-Search-1.iml)

The student needs to submit actual code that implements the solution to the problem. The current submission appears to be an accidental file upload (an IDE configuration file). To pass this problem, the student should:

  1. Implement a binary search algorithm that handles the rotated sorted array case
  2. Check both halves of the array to determine which half is sorted
  3. Adjust search boundaries based on whether target lies in the sorted half or the rotated half
  4. Return -1 if target is not found

The reference solution demonstrates the correct approach using the standard rotated array binary search pattern.

VERDICT: NEEDS_IMPROVEMENT


Search Inside a Sorted Array whose Length is unknown (.idea/.gitignore)

  1. Missing Solution: The student has not provided any code that addresses the problem. The submitted file is a .gitignore file, which is typically used for Git version control configuration, not for solving algorithmic problems.

  2. What Was Expected: The student should have submitted a solution implementing the exponential search approach:

    • First, find the bounds of the array by exponentially expanding the search range (doubling high until reader.get(high) >= target or out-of-bounds marker)
    • Then perform binary search within those bounds to locate the target
  3. How to Improve:

    • Submit a proper C++ solution (or language of choice) that implements the search function with the ArrayReader& reader and int target parameters
    • Follow the reference solution structure which correctly handles the unknown array size
    • Ensure the code compiles and handles edge cases properly

The student needs to provide actual code solving the problem rather than configuration files.

VERDICT: NEEDS_IMPROVEMENT


Search a 2D Matrix (.idea/misc.xml)

The student needs to submit an actual solution to the problem. The reference solution demonstrates a correct approach using binary search on a flattened 2D matrix (treating the 2D array as a 1D sorted array). Key aspects of a good solution should include:

  1. Binary Search Implementation: Treat the 2D matrix as a 1D sorted array and perform binary search with indices converted to row/column positions.
  2. Index Calculation: Use row = mid / n and col = mid % n to map the 1D index back to 2D coordinates.
  3. Edge Case Handling: Ensure proper handling of empty matrices and single-element cases.
  4. Time Complexity: Achieve O(log(m*n)) as required by the problem.

The student should write and submit a complete Java solution implementing the binary search algorithm for the "Search a 2D Matrix" 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