Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sqrt Decomposition notation #879

Open
@jxu

Description

@jxu

Article:Sqrt Decomposition

Problem:
I think in math terms it's usually cleaner to think about intervals a[l,r) (begin index inclusive, end index exclusive) than a[l,r] (both inclusive). If you look at the structure of a for loop, we have termination condition i < n instead of i <= n-1. (Interestingly,Dijkstra covered why this is more natural as the length of the interval is just the difference between the bounds, so prevents messy "-1" factors floating around. )

So to make it easier to grasp what's going on without being obscured by indexing, the case without l and r being in the same block can be written

    for (int i=l; i<(c_l+1)*s; ++i) // use s instead of len to be consistent with article        sum += a[i];    for (int k=c_l+1; k<c_r; ++k) // use k for block index to prevent confusion        sum += b[k];    for (int i=c_r*s; i<=r; ++i)        sum += a[i];

Also we set s, both the block size and number of blocks for simplicity, to be ceil(sqrt(n)) so that s*s is >= n? Should be clarified.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp