Skip to content

Lecture 15: Book Allocation Problem  #569

@ishansurdi

Description

@ishansurdi
  1. Problem: When the current student's page sum exceeded mid, the code incorrectly added the book's pages to pagesum instead of starting a new student's allocation.
    Impact: Incorrect allocation logic caused feasibility checks to fail.
    Binary Search Midpoint Calculation:

  2. Problem: mid was calculated as sum + (end - sum) / 2, which used the wrong boundaries (sum instead of start).
    Impact: Binary search did not narrow down the range correctly.
    No Edge Case Handling (m > n):

  3. Problem: The code didn't check if the number of students (m) was greater than the number of books (n).
    Impact: Returned incorrect results when allocation was impossible.
    Incorrect Return Value:

  4. Problem: The function always returned -1 due to misplaced logic.
    Impact: Even valid allocations failed to return the correct result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions