Skip to content

Access of PreCourse-2 PR - #1895

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

Access of PreCourse-2 PR#1895
venkatayedupati wants to merge 1 commit into
super30admin:masterfrom
venkatayedupati:master

Conversation

@venkatayedupati

Copy link
Copy Markdown

No description provided.

@venkatayedupati venkatayedupati changed the title access of repo Done Access PreCourse-2 PR Aug 31, 2026
@venkatayedupati venkatayedupati changed the title Access PreCourse-2 PR Access of PreCourse-2 PR Aug 31, 2026
@super30admin

Copy link
Copy Markdown
Owner

The student's solution is incomplete. The binarySearch method has no implementation - it only contains a comment indicating where code should be written. The method needs to:

  1. Implement the actual binary search algorithm
  2. Calculate the middle index
  3. Compare the middle element with the target value
  4. Recursively or iteratively search the appropriate half
  5. Handle the base case when the search space is exhausted

A proper implementation would look something like:

int binarySearch(int arr[], int l, int r, int x) {
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x) return mid;
        if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

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