السلام عليكم ورحمة الله وبركاته
أخواني الأعزاء .. كتبت هذا الموضوع في كثير من المنتديات ولكن لم أجد أي إجابة شافية وفي منتديات انجليزية أيضاً ولم يجبني أحد
حتى لا أطيل عليكم .. المسألة وما فيها هي أني ..
أريد عمل برنامج في الفيجول بيسك يقوم فيه المستخدم بإدخال عناصر مجموعة أي عدد خمسة عناصر أو ثلاثة عناصر .. أو n من العناصر
ومن ثم يقوم البرنامج بطباعة المجموعات الجزئية ... كل المجموعات الجزئية !!!!!!!
كيف يمكن عمل ذلك بالفيجول بيسك ؟؟
وأنا أملك خوارزمية باللغة الإنجليزية لحل مثل هذه المشكلة ولكن لم يحالفني الحظ والفهم لاستغلالها أضغها لكم ربما تستفيدون منها
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
وأرجو الاهتمام بالموضوع وأخذه بجدية
وأشكركم من أعماق قلبي مقدماً على أي رد أو أي مواساة