usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< PreviousNext >>

Code for Combination (Selection Without Repetition) in VB.Net



Code for Doing Combination in VB.Net

Writing up an algorithm to carry out the different Combination - Selection without Repetition, nCr - of a set of things in VB.Net requires some level of imaginative thinking.

Get a writing pad and pencil:
  1. Write out all n members in the set - for Combination - at the top of the pad.
  2. Beginning with the first member, match it separately with the other members until the required selected-group size (r) is reached.
  3. When every possible Combination for this first member is exhausted, remove the current first member from the mother set.
    The immediate next member becomes the new first member in the culminating set.
  4. Take the first member in what is left of the mother set and repeat the same process from step II.

How to carry out combination

This is exactly what we will do with code to list up all possible selections without repetition in VB.Net.

Create a new Visual Basic project; call it Miscellaneous_VS.
You can rename the module name -- just right-click on the name from the Solution Explorer panel -- to Miscellaneous_Combination if you want.

Create a new Visual Basic class file; call it Combination.

Type out the adjoining VB.Net algorithm for the combination of different options (nCr).



Why Bother About Combination

Well, isn't it obvious?
Say you are to pick only four (4) pupils from a class of six - such a small class; our little Combination algorithm solves this little problem for you by showing all your possible options / selection outcomes.









<< PreviousNext >>