Results 1 to 2 of 2

Thread: help ... how can make this program

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    2

    help ... how can make this program

    how can make program with vb
    using this alogarithm
    subsets of a set

    three algorithms are described to answer the problem how to generate all the subsets of a finite set

    algorithm : to generate all the subsets of a finite set.

    input: a set a{x1,x2,...,xn}
    output: all the subsets of s

    the idea behind the algorith is ti construct a characteristis function to identify the elements of s for each subset. if s has n elements , the binary strtings with n digits serve the purpose. for a given binary string , each digit corresponds to an x in s. if the digit is 1 then include x in the subset; if the digit is 0 then exclude x .

    method : m <--- 0

    while m < 2^n :

    express m as a binary string of length n
    (m=a1 2^n + a2 2n^n-1 + ... + an 2^0)
    define the characteristic function
    ( ci <--- ai for i=1,2,...,n)
    choose the subset y correspnding to m
    (if ci = 1 then include xi in y)
    record y (print or store in a file)
    m <--- m+1

    Example 1 : find all the subset of s ={a,b,c} using algorith

    method : if the set s is empty , then fiy is the only subset of s ; record fiy

    otherwise select arbitraily an element x ( s
    find all the subsets of s - {X} and
    for each subset y of s={x} , record {x} U y .

    the idea behind this algorith is to use a recursive aproach . the statment find all the subset of (s-{X}) invoves a recursive call. the sets s,s-{x} , ... form a strictly decreasing sequence , for each set is a proper subset of the noe befor. the sequence must end with the empty set , fiy , since s is finite
    hence the recursion will terminate

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: help ... how can make this program

    Could you elaborate on this section?

    Originally posted by taroot
    otherwise select arbitraily an element x ( s
    find all the subsets of s - {X} and
    for each subset y of s={x} , record {x} U y .
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width