BS Artificial Intelligence · Semester 1 · Week 12

Discrete Mathematics for BSAI

Permutations, Combinations and Feature Sets

Dr. Hira Benish
Associate Professor & HoD, Mathematics
PMAI Lab, Mathematics Behind AI

Week 12 · Dr. Hira BenishBegin reading  

01 · Opening Challenge: Same Features, Different Order?

A learning-support team has eight candidate measurements. It can select three for a dashboard, or rank the top three in first, second and third place. Are those two tasks asking for the same number?

Predict: The selections {Q,E,A} and {A,Q,E} contain the same measurements. The rankings (Q,E,A) and (A,Q,E) assign different roles. Week 11 counted 8×7×6=336 rankings. We now find how many distinct selected sets those rankings represent.

Central question

When do different written orders represent genuinely different outcomes, and when are they repeated descriptions of one choice?

02 · Learning Objectives and Three-Hour Guide

By the end of Week 12, you should be able to count ordered assignments with simple restrictions; group ordered listings that give one unordered selection; explain factorial, permutation and combination notation; choose an appropriate counting method; and complete the eight-feature case with justified counts and limits on interpretation.

Class timeEssential work
50 minRestricted arrangements and order checks
55 minSelections, grouping, factorial and combinations
60 minMajor Case Study 3 resolution and peer explanation
15 minShort count-and-justify check

Classroom essentials Sections 01–11 and Practice 1–6. Optional self-study Colab and Practice 7–8. List tiny outcomes before relying on a formula.

03 · First Count Ordered Positions

Four distinct applicants fill the roles of chairperson and deputy, with no person in both roles. There are four choices for chairperson. Once chosen, three remain for deputy: 4×3=12 assignments. Swapping the two people changes who has which role.

With n distinct candidates and r ordered positions, filled without reuse, the number of choices decreases one by one:

n×(n−1)×(n−2)×··· for r factors.

Worked ranking

Choose first, second and third place from five distinct cards: 5×4×3=60. One outcome is an ordered triple such as (A,C,E). The triple (C,A,E) is another outcome because first and second place were exchanged.

Quick check: 5×5×5 would allow the same card in several positions. Here each card can be used only once.

04 · Apply a Restriction Before Multiplying

With five distinct applicants, assign a chairperson and deputy. If applicant A must be chairperson, the first position has one choice and the deputy has four: 1×4=4. If A cannot be chairperson, the first position has four choices, and each leaves four people for deputy: 4×4=16.

ConditionFirst positionSecond positionAssignments
No restriction5420
A first144
A not first4416

The final check 4+16=20 works because “A first” and “A not first” are separate cases covering every unrestricted assignment. The repeated number 4 in 4×4 has two different meanings: four eligible first choices, then four remaining people for the second role.

05 · Group Orders That Make the Same Selection

From three distinct codes Q, E, A, Week 11 listed six ordered pairs: QE, QA, EQ, EA, AQ, AE. But choosing two codes for a set has only three outcomes:

Selected setOrdered pairs describing it
{Q,E}QE and EQ
{Q,A}QA and AQ
{E,A}EA and AE

Each two-element set was counted twice in the ordered list. Therefore 3×2÷2=3 selections. More generally, for three selected distinct objects, there are 3×2×1=6 internal orders of those same objects. Dividing an ordered count by six gives the number of three-object selections when every selected triple has all six possible orders and there are no restrictions favoring one order.

Six ordered pairs group into three unordered two-feature sets QE, EQQA, AQEA, AE {Q,E}{Q,A}{E,A}
Figure 1. Reversing an ordered pair changes the ranking, but not the two-element set.

06 · Factorial Is Shorthand for a Falling Product

For a positive whole number n, factorial is the product n!=n×(n−1)×···×2×1. For example, 4!=4×3×2×1=24. We set 0!=1; this makes the counting formulas work when no choices remain to be arranged.

5!=5×4×3×2×1=120; 3!=3×2×1=6.

Factorial is a compact way to write a product, not a new kind of outcome. To count only the first three ordered positions from five, use 5×4×3=60, not all 5!=120 full arrangements.

07 · Compact Notation After the Reasoning

Let 0≤r≤n. We use P(n,r), also written ₙPᵣ, for ordered arrangements of r distinct choices from n without reuse. Its formula shortens the falling product:

P(n,r)=n!/(n−r)!.

We use C(n,r), also written (ⁿᵣ) or “n choose r,” for unordered selections. Each selected set of r distinct objects appears in r! different orders, so:

C(n,r)=P(n,r)/r!=n!/[r!(n−r)!].

Five objects, choose three

Ordered: P(5,3)=5×4×3=60. Each three-object set has 3!=6 orders, so unordered: C(5,3)=60÷6=10. The division corrects repeated descriptions of the same selection.

These formulas require distinct objects, no repetition, and the stated order interpretation. For a small task, a list or stage-by-stage count is often clearer than substituting immediately.

08 · Choose the Counting Method

Ask first: What counts as one outcome? Are there separate cases, consecutive stages, overlapping groups, or a forced shared category? If selecting several objects, does swapping their positions change the result?
StructureUseful approachSmall cue
Separate, nonoverlapping casesAddOne soup or one salad
Consecutive stagesMultiply branch countsOne route and one mode
Two overlapping groupsAdd, then subtract overlapChose coding or design
More objects than a capacity permitsPigeonhole argumentSeven files in three folders
Distinct roles / order mattersOrdered stage count, P(n,r)First and second place
Only membership mattersGroup repeated orders, C(n,r)Select a feature set

Problems may combine methods. For example, a restriction can be applied first, followed by a product count; disjoint restricted cases can then be added. Give a reason for each step.

09 · Choice or Rank?

Predict → Test → Explain Each card asks for a count. Identify whether roles matter, select an answer, and read the correction for repeated orders or restrictions.

Challenge 1 of 6

Predict before selecting.

10 · Major Case Study 3 Concludes: Exploring Possible Feature Sets

Scenario → Understand → Represent → Reason → Check → Interpret. We continue with the same eight distinct candidate measurements from Week 11. No measurement may be repeated within a set or ranking.

CodeCandidate measurementCodeCandidate measurement
QQuizzes completedEExercises attempted
APractice accuracyTTime between attempts
RRevision sessionsMMissed checkpoints
HHints requestedCTopics completed

Understand and represent

A two-feature set treats {Q,E} and {E,Q} as the same outcome. An ordered pair treats (Q,E) and (E,Q) as different. A ranking of the top three also uses distinct positions.

Reason: base counts

QuestionReasonCount
Ordered pairs8 first choices, then 7 remaining second choices8×7=56
Two-feature setsEach set appears in 2 orders; 56÷2C(8,2)=28
Ranked top three8 first, 7 second, 6 thirdP(8,3)=336
Three-feature setsEach set appears in 3!=6 orders; 336÷6C(8,3)=56

Reason: a required measurement

Suppose every selected pair must contain Q. Fix Q and choose its partner from the seven other codes: 7 sets. Do not multiply by two: {Q,E} and {E,Q} are one set. If every selected triple must contain Q, choose two from the other seven: C(7,2)=7×6÷2=21 triples.

Reason: an incompatible pair

For a hypothetical design constraint, say Q and E may not appear together in a selected pair. Among 28 two-feature sets, exactly one is the forbidden set {Q,E}. Therefore 28−1=27 valid two-feature sets. If Q is also required, its allowed partner is one of the other six codes, so 6 valid pairs. The incompatibility is an exercise condition, not a finding about the actual measurements.

Check and submit

Check the ordered-pair count against the set count: 28×2=56. Check the triple count: 56×6=336. A case submission should state (1) what one outcome is, (2) whether order matters, (3) the count and reason for each row above, (4) the two restrictions, and (5) one sentence about what these counts cannot tell us.

11 · What the Counts Mean

The result 28 counts possible two-feature sets under the stated distinctness rule. It does not tell us whether any pair is useful. The result 27 depends on the additional prohibition of {Q,E}; removing that policy returns 28. The result 56 for three-feature sets is an inventory of possible selections, not a score for the best dashboard.

Interpretation limit: Choosing candidate measurements for a real system would also require evidence about data quality, relevance, fairness, and performance. Counting alone evaluates none of these properties.

12 · Optional Colab: Check a Hand Count

Self-study · mathematics first First list the six two-feature sets from four codes Q,E,A,T: QE, QA, QT, EA, ET, AT. Python can verify the count after you have reasoned that C(4,2)=4×3÷2=6.

1 · Reuse loops and indices

range(4) supplies positions 0,1,2,3. For a chosen first position i, range(i + 1, 4) supplies only positions after it, so the pair is printed once and no code is paired with itself.

features = ["Q", "E", "A", "T"]
for i in range(4):
    for j in range(i + 1, 4):
        print(features[i], features[j])

Predict the six printed pairs before running. This small list checks your hand enumeration; it does not prove a general formula on its own.

2 · Optional ready-made enumeration

The standard-library function combinations lists selections without order. import makes that function available. With the same four-code list, the printed result should again contain six pairs.

from itertools import combinations
features = ["Q", "E", "A", "T"]
print(list(combinations(features, 2)))

To check the eight-feature case, extend the list to all eight codes and change nothing else. The output should contain C(8,2)=28 pairs; explain why it prints (Q,E) only once and no (E,Q) separately.

13 · Practice and Case Submission

Decide first whether order matters, then justify the count. Selected solutions are at the end.

  1. From five distinct books, select two to borrow. Count selections. Separately, how many first-and-second reading orders can be formed from the five books?
  2. From six distinct applicants, rank first, second and third. Count rankings. How many three-applicant sets?
  3. Four distinct tasks are arranged in a row. How many orders? Expand the factorial rather than giving only a symbol.
  4. From five distinct applicants, assign chairperson and deputy, but applicant A must be chairperson. Count. Repeat when A cannot be chairperson.
  5. For the eight case-study features, count selected pairs containing Q. How many selected pairs remain if {Q,E} is forbidden? How many remain if both restrictions apply?
  6. For eight features, find the number of three-feature sets by grouping the 336 rankings. Explain exactly why you divide by 3!.
  7. At a student event, 12 joined coding, 10 joined design, and 3 joined both. How many joined at least one? State the counting method.
  8. Seven papers are distributed among three folders. What minimum folder size is guaranteed? Give a short capacity argument.

Major Case Study 3 submission prompt

Using the eight-code table in Section 10, submit a one-page case record with counts for ordered pairs, selected pairs, ranked triples, selected triples, pairs requiring Q, pairs excluding {Q,E}, and pairs satisfying both restrictions. Show how you avoid counting repeated orders. End with the interpretation limit in your own words.

15-minute exit check: “Select two of five distinct cards” versus “award first and second to two of five distinct cards.” Give both counts and one sentence explaining the difference.

14 · Common Mistakes

Tempting moveRepair
Use P(8,2) for an unordered feature pair.Each pair appears in two orders; use C(8,2)=28.
Divide every restricted ranking count by r! automatically.First verify each selected set still has the same allowed number of orderings under the restriction.
Use 5! for three ordered positions from five items.Stop after three factors: 5×4×3=60.
Count {Q,E} and {E,Q} as separate sets.Order is absent from a set; they are identical selections.
Exclude both QE and EQ separately from an unordered-pair count.There is only one forbidden set {Q,E} among the 28 sets.
Conclude that the most numerous feature type predicts best.Counts measure possibilities, not relevance or model performance.

15 · Summary

  • For ordered positions without reuse, multiply the number of remaining choices at each stage: P(n,r)=n!/(n−r)!.
  • For selections without order, each selected set has r! orders: C(n,r)=P(n,r)/r!.
  • Factorial is a product shorthand, with 0!=1.
  • Handle a restriction by defining allowed outcomes first; add separate cases or subtract forbidden outcomes only when they have been counted correctly.
  • In the eight-feature case, there are 56 ordered pairs, 28 two-feature sets, 336 ranked triples, and 56 three-feature sets under the stated assumptions.

16 · Visual Concept Map

Define an outcome; if order matters count ordered positions, otherwise group repeated orders; then apply and check restrictions DEFINE ONE OUTCOMEORDER MATTERSORDER DOES NOT MATTERAPPLY RESTRICTIONS Does swapping change it?P(n,r): remaining choicesC(n,r): group r! ordersRequired? Forbidden? Count once.
Use notation only after deciding what counts as a distinct outcome.

17 · Looking Ahead

Week 13 begins graph theory. We will model buildings and walkways as vertices and edges, then examine routes that inspect each walkway. The skill of stating exactly what counts as a distinct object or route continues to matter.

Selected Solutions

Choice or Rank?

1: 4×3=12 rankings. 2: 12÷2=6 selections, because each pair has two orders. 3: 5×4×3=60 rankings. 4: 60÷3!=10 selections. 5: 1×4=4 assignments with A first. 6: 4×4=16 assignments with A not first.

1 · Books

C(5,2)=5×4÷2=10 two-book sets. Ranking first and second from five gives P(5,2)=5×4=20 reading orders.

2 · Applicants

P(6,3)=6×5×4=120 rankings; each set has 3!=6 rankings, so C(6,3)=120÷6=20 sets.

3 · Four tasks

4!=4×3×2×1=24 full orders.

4 · Restricted roles

A first: 1×4=4. A not first: 4×4=16. These separate cases sum to the unrestricted 5×4=20.

5–6 · Feature sets

Pairs containing Q: 7. Excluding {Q,E} from all 28 pairs leaves 27. Requiring Q and excluding E leaves 6. Three-feature sets: 336÷3!=336÷6=56, because each chosen triple can be placed in six distinct orders.

7 · Overlap

12+10−3=19 students joined at least one; subtract the double-counted overlap once.

8 · Folder guarantee

If each folder held at most two papers, three folders would hold at most six. Seven papers therefore force some folder to have at least three.

Exit check

Selected pairs: C(5,2)=10. Awarding first and second: P(5,2)=20. Each selected pair can be ordered in two ways.