Preview:
SumOfSub(s, k, r)
{
    // Generate left child
    x[k] = 1
    if (s + w[k] == m) then
        write(x[1 : k]) // Subset found
    else if (s + w[k] + w[k + 1] <= m) then
        SumOfSub(s + w[k], k + 1, r - w[k])

    // Generate right child and evaluate conditions
    if ((s + r - w[k] >= m) and (s + w[k + 1] <= m)) then
    {
        x[k] = 0
        SumOfSub(s, k + 1, r - w[k])
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter