Discrete MathematicsDiscrete Mathematics

Logic, sets, counting, recurrences, graphs, and number theory — the math language of computer science.Logic, sets, counting, recurrences, graphs আর number theory — computer science-এর math ভাষা।

1. Propositional Logic1. Propositional Logic

A proposition is a statement that is either true (T) or false (F). It cannot be both.

  • "5 is a prime number." — This is a proposition. It is true.
  • "2 + 2 = 5." — This is a proposition. It is false.
  • "What time is it?" — Not a proposition. A question has no truth value.
  • "x + 1 = 3" — Not a proposition by itself. It depends on x.

We use small letters like \( p, q, r \) to name propositions.

Proposition হলো এমন একটি statement যা হয় true (T) না হয় false (F)। দুটো একসাথে হতে পারে না।

  • "5 একটি prime number।" — এটি একটি proposition। এটি true।
  • "2 + 2 = 5।" — এটি একটি proposition। এটি false।
  • "এখন কয়টা বাজে?" — এটি proposition না। প্রশ্নের কোনো truth value নেই।
  • "x + 1 = 3" — এটি নিজে proposition না। এটা x-এর উপর নির্ভর করে।

Proposition-এর নাম দিতে আমরা ছোট হাতের letter ব্যবহার করি, যেমন \( p, q, r \)।

Logical connectivesLogical connectives

We join propositions with connectives. These are the main ones:

Connective দিয়ে আমরা proposition জোড়া লাগাই। প্রধান connective গুলো হলো:

Nameনাম Symbol Meaningঅর্থ True when...কখন true...
Negation (NOT) \( \neg p \) not pp না p is falsep false হলে
Conjunction (AND) \( p \land q \) p and qp এবং q both are trueদুটোই true হলে
Disjunction (OR) \( p \lor q \) p or q (or both)p অথবা q (বা দুটোই) at least one is trueঅন্তত একটি true হলে
Exclusive OR (XOR) \( p \oplus q \) exactly one of themঠিক একটি true they are differentদুটো ভিন্ন হলে
Implication \( p \rightarrow q \) if p then qযদি p হয় তবে q always, except when p is T and q is Fসবসময়, শুধু p true আর q false হলে ছাড়া
Biconditional \( p \leftrightarrow q \) p if and only if qp if and only if q both have the same valueদুটোর value একই হলে

Truth tablesTruth tables

A truth table lists every possible combination of truth values. With 2 variables there are \( 2^2 = 4 \) rows. With \( n \) variables, \( 2^n \) rows.

Truth table-এ truth value-এর সব possible combination থাকে। 2টি variable হলে \( 2^2 = 4 \) টি row। \( n \) টি variable হলে \( 2^n \) টি row।

\( p \)\( q \)\( \neg p \)\( p \land q \)\( p \lor q \)\( p \oplus q \)\( p \rightarrow q \)\( p \leftrightarrow q \)
TTFTTFTT
TFFFTTFF
FTTFTTTF
FFTFFFTT
Exam trap: The implication \( p \rightarrow q \) is FALSE only in ONE case: when \( p \) is true and \( q \) is false. If \( p \) is false, the whole implication is TRUE — no matter what \( q \) is. Example: "If 2 > 5, then cows can fly" is a TRUE statement, because the "if" part is false. BUET exams love this trap.
Exam trap: Implication \( p \rightarrow q \) শুধু একটি case-এ FALSE হয়: যখন \( p \) true আর \( q \) false। যদি \( p \) false হয়, পুরো implication TRUE — \( q \) যা-ই হোক। উদাহরণ: "যদি 2 > 5 হয়, তাহলে গরু উড়তে পারে" — এটা একটা TRUE statement, কারণ "if" অংশটা false। BUET exam-এ এই trap খুব আসে।

Tautology, contradiction, contingencyTautology, contradiction, contingency

  • Tautology: always true. Example: \( p \lor \neg p \).
  • Contradiction: always false. Example: \( p \land \neg p \).
  • Contingency: sometimes true, sometimes false. Example: \( p \rightarrow q \).
  • Tautology: সবসময় true। উদাহরণ: \( p \lor \neg p \)।
  • Contradiction: সবসময় false। উদাহরণ: \( p \land \neg p \)।
  • Contingency: কখনো true, কখনো false। উদাহরণ: \( p \rightarrow q \)।
Example: Show that \( (p \land (p \rightarrow q)) \rightarrow q \) is a tautology (this rule is called modus ponens).
\( p \)\( q \)\( p \rightarrow q \)\( p \land (p \rightarrow q) \)whole formula
TTTTT
TFFFT
FTTFT
FFTFT
The last column is all T. So it is a tautology.
Example: দেখাও যে \( (p \land (p \rightarrow q)) \rightarrow q \) একটি tautology (এই rule-এর নাম modus ponens)।
\( p \)\( q \)\( p \rightarrow q \)\( p \land (p \rightarrow q) \)পুরো formula
TTTTT
TFFFT
FTTFT
FFTFT
শেষ column-এর সব value T। তাই এটি tautology।

Logical equivalence and De Morgan's lawsLogical equivalence এবং De Morgan's laws

Two formulas are logically equivalent (written \( \equiv \)) if they have the same truth table. The most important laws:

দুটি formula logically equivalent (লেখা হয় \( \equiv \)) যদি তাদের truth table একই হয়। সবচেয়ে গুরুত্বপূর্ণ law গুলো:

LawLawEquivalenceEquivalence
De Morgan's law 1\( \neg(p \land q) \equiv \neg p \lor \neg q \)
De Morgan's law 2\( \neg(p \lor q) \equiv \neg p \land \neg q \)
Double negation\( \neg(\neg p) \equiv p \)
Implication as OR\( p \rightarrow q \equiv \neg p \lor q \)
Contrapositive law\( p \rightarrow q \equiv \neg q \rightarrow \neg p \)
Distributive\( p \land (q \lor r) \equiv (p \land q) \lor (p \land r) \)
Absorption\( p \lor (p \land q) \equiv p \)
Example: Prove \( \neg(p \rightarrow q) \equiv p \land \neg q \).
Step 1: replace the implication: \( p \rightarrow q \equiv \neg p \lor q \).
Step 2: negate it: \( \neg(\neg p \lor q) \).
Step 3: apply De Morgan: \( \neg(\neg p) \land \neg q \).
Step 4: double negation: \( p \land \neg q \). Done.
In words: "if p then q" is false exactly when p happens but q does not.
Example: প্রমাণ করো \( \neg(p \rightarrow q) \equiv p \land \neg q \)।
Step 1: implication বদলাও: \( p \rightarrow q \equiv \neg p \lor q \)।
Step 2: negate করো: \( \neg(\neg p \lor q) \)।
Step 3: De Morgan apply করো: \( \neg(\neg p) \land \neg q \)।
Step 4: double negation: \( p \land \neg q \)। শেষ।
সহজ কথায়: "যদি p তবে q" তখনই false যখন p ঘটে কিন্তু q ঘটে না।

Converse, inverse, contrapositiveConverse, inverse, contrapositive

Start with the implication \( p \rightarrow q \):

  • Converse: \( q \rightarrow p \) — swap the two sides.
  • Inverse: \( \neg p \rightarrow \neg q \) — negate both sides.
  • Contrapositive: \( \neg q \rightarrow \neg p \) — swap AND negate.

Key fact: only the contrapositive is equivalent to the original. The converse and inverse are equivalent to each other, but NOT to the original.

Implication \( p \rightarrow q \) থেকে শুরু করি:

  • Converse: \( q \rightarrow p \) — দুই পাশ অদল-বদল।
  • Inverse: \( \neg p \rightarrow \neg q \) — দুই পাশ negate।
  • Contrapositive: \( \neg q \rightarrow \neg p \) — অদল-বদল এবং negate দুটোই।

মূল কথা: শুধু contrapositive মূল statement-এর equivalent। Converse আর inverse একে অপরের equivalent, কিন্তু মূলটার সাথে NOT equivalent।

Example: Statement: "If it rains, the road is wet." \( (p \rightarrow q) \)
Converse: "If the road is wet, it rains." (Not always true — maybe someone washed the road.)
Inverse: "If it does not rain, the road is not wet." (Same problem.)
Contrapositive: "If the road is not wet, it did not rain." (Always matches the original.)
Example: Statement: "যদি বৃষ্টি হয়, রাস্তা ভেজা থাকে।" \( (p \rightarrow q) \)
Converse: "যদি রাস্তা ভেজা থাকে, তাহলে বৃষ্টি হয়েছে।" (সবসময় true না — কেউ হয়তো রাস্তা ধুয়েছে।)
Inverse: "যদি বৃষ্টি না হয়, রাস্তা ভেজা না।" (একই সমস্যা।)
Contrapositive: "যদি রাস্তা ভেজা না থাকে, বৃষ্টি হয়নি।" (মূল statement-এর সাথে সবসময় মেলে।)

Quantifiers: ∀ and ∃Quantifiers: ∀ এবং ∃

  • \( \forall x \, P(x) \) — "for all x, P(x) is true" (universal quantifier).
  • \( \exists x \, P(x) \) — "there exists at least one x for which P(x) is true" (existential quantifier).

Example: over integers, \( \forall x \, (x^2 \ge 0) \) is true. \( \exists x \, (x^2 = 2) \) is false over integers (no integer squared gives 2).

Negating quantified statements — the negation flips the quantifier and moves inside:

  • \( \forall x \, P(x) \) — "সব x-এর জন্য P(x) true" (universal quantifier)।
  • \( \exists x \, P(x) \) — "অন্তত একটি x আছে যার জন্য P(x) true" (existential quantifier)।

উদাহরণ: integer-এর উপর \( \forall x \, (x^2 \ge 0) \) true। কিন্তু \( \exists x \, (x^2 = 2) \) integer-এর উপর false (কোনো integer-এর square 2 হয় না)।

Quantified statement-এর negation — negation করলে quantifier উল্টে যায় আর negation ভিতরে ঢোকে:

\[ \neg \forall x \, P(x) \equiv \exists x \, \neg P(x) \qquad\qquad \neg \exists x \, P(x) \equiv \forall x \, \neg P(x) \]
Example: Negate: "All students passed the exam." \( \forall x \, \text{Passed}(x) \)
Negation: "There exists at least one student who did NOT pass." \( \exists x \, \neg\text{Passed}(x) \)
Wrong answer (common mistake): "All students failed." That is too strong. One failing student is enough to break "all passed".
Example: Negate করো: "সব student exam-এ pass করেছে।" \( \forall x \, \text{Passed}(x) \)
Negation: "অন্তত একজন student আছে যে pass করেনি।" \( \exists x \, \neg\text{Passed}(x) \)
ভুল উত্তর (common mistake): "সব student fail করেছে।" এটা অতিরিক্ত strong। "সবাই pass" ভাঙতে একজন fail করলেই যথেষ্ট।
Note: With nested quantifiers, order matters. \( \forall x \, \exists y \, (y > x) \) says "for every number there is a bigger one" — true. But \( \exists y \, \forall x \, (y > x) \) says "there is one number bigger than all numbers" — false.
Note: Nested quantifier-এ order গুরুত্বপূর্ণ। \( \forall x \, \exists y \, (y > x) \) মানে "প্রতিটি number-এর চেয়ে বড় একটা number আছে" — true। কিন্তু \( \exists y \, \forall x \, (y > x) \) মানে "এমন একটা number আছে যা সব number-এর চেয়ে বড়" — false।

Knights and Knaves — Liar/Truth-teller Riddles (Real Exam!)Knights and Knaves — Liar/Truth-teller Riddles (Real Exam!)

In these riddles, every person is one of two types: a knight (always tells the truth) or a knave (always lies). Your job: find who is who, or get correct information out of them.

The famous two-roads trick: You reach a fork. One road leads to the village, the other to danger. Two people stand there: one always truthful, one always a liar — but you do not know who is who. You may ask only ONE question to ONE of them.

Magic question: "If I asked the other person which road leads to the village, what would they say?" Then take the opposite road.

Why it works — both people give the same (wrong) answer:

  • You asked the truth-teller: he truthfully reports the liar's lie → you hear the wrong road.
  • You asked the liar: he lies about the truth-teller's true answer → you hear the wrong road.

One truth passed through one lie is always a lie. So the answer you hear is guaranteed wrong — just flip it. The same trick works with one person of unknown type: ask "If I asked YOU whether the left road leads to the village, what would you say?" A lie about a lie becomes the truth, so this answer is always correct.

এই riddle-গুলোতে প্রতিটি মানুষ দুই type-এর একটি: knight (সবসময় সত্যি বলে) অথবা knave (সবসময় মিথ্যা বলে)। তোমার কাজ: কে কী তা বের করা, অথবা তাদের কাছ থেকে সঠিক তথ্য আদায় করা।

বিখ্যাত two-roads trick: তুমি একটি মোড়ে পৌঁছালে। একটি রাস্তা village-এ যায়, অন্যটি বিপদে। সেখানে দুইজন মানুষ: একজন সবসময় সত্যবাদী, একজন সবসময় liar — কিন্তু কে কোনটা তুমি জানো না। তুমি শুধু একজনকে একটি প্রশ্ন করতে পারবে।

Magic question: "আমি যদি অন্যজনকে জিজ্ঞেস করতাম কোন রাস্তা village-এ যায়, সে কী বলত?" তারপর উল্টো রাস্তা নাও।

কেন কাজ করে — দুজনই একই (ভুল) উত্তর দেয়:

  • সত্যবাদীকে জিজ্ঞেস করলে: সে liar-এর মিথ্যাটা সত্যি করে জানায় → তুমি ভুল রাস্তা শুনবে।
  • Liar-কে জিজ্ঞেস করলে: সে সত্যবাদীর সত্যি উত্তর নিয়ে মিথ্যা বলে → তুমি ভুল রাস্তা শুনবে।

একটি সত্যি একটি মিথ্যার ভিতর দিয়ে গেলে ফলাফল সবসময় মিথ্যা। তাই যে উত্তর শুনবে সেটা নিশ্চিত ভুল — শুধু উল্টে নাও। অজানা type-এর একজন মানুষ থাকলেও একই trick: জিজ্ঞেস করো "আমি যদি তোমাকেই জিজ্ঞেস করতাম বাম রাস্তা village-এ যায় কি না, তুমি কী বলতে?" মিথ্যার উপর মিথ্যা হয়ে যায় সত্যি, তাই এই উত্তর সবসময় সঠিক।

Real exam: BUET asked liar/truth-teller riddles in October 2017 and again in October 2018 (a truthful person vs a liar at a platform). Learn the "ask about the other person, then flip the answer" technique — it solves most versions.
Real exam: BUET October 2017-এ এবং আবার October 2018-এ liar/truth-teller riddle জিজ্ঞেস করেছে (platform-এ একজন সত্যবাদী বনাম একজন liar)। "অন্যজনের কথা জিজ্ঞেস করো, তারপর উত্তর উল্টাও" — এই technique শিখে রাখো, বেশিরভাগ version এতেই solve হয়।
Example (worked riddle): On an island, A says: "We are both knaves." What are A and B?
Check every case, truth-table style:
ABA's statement "both knaves"Consistent?
knightknightfalse✗ a knight cannot say a false thing
knightknavefalse✗ same problem
knaveknightfalse✓ a knave says a false thing — OK
knaveknavetrue✗ a knave cannot say a true thing
Only one row survives: A is a knave, B is a knight.
Shortcut logic: if A were truthful, his own statement would make him a liar — contradiction. So A lies. Then "we are both knaves" is false, so at least one of them is truthful — it is not A, so it must be B.
Example (worked riddle): একটি দ্বীপে A বলল: "আমরা দুজনেই knave।" A আর B কী?
Truth table-এর মতো প্রতিটি case check করি:
ABA-এর statement "both knaves"Consistent?
knightknightfalse✗ knight মিথ্যা বলতে পারে না
knightknavefalse✗ একই সমস্যা
knaveknightfalse✓ knave মিথ্যা বলে — ঠিক আছে
knaveknavetrue✗ knave সত্যি বলতে পারে না
শুধু একটি row টিকে থাকে: A হলো knave, B হলো knight।
Shortcut logic: A সত্যবাদী হলে তার নিজের statement-ই তাকে liar বানায় — contradiction। তাই A মিথ্যা বলে। তাহলে "আমরা দুজনেই knave" false, অর্থাৎ অন্তত একজন সত্যবাদী — সেটা A না, তাই অবশ্যই B।

Strong Induction — the Stamp Problem (Real Exam!)Strong Induction — the Stamp Problem (Real Exam!)

Mathematical induction proves a statement \( P(n) \) for all \( n \) from some start: first prove the base case, then the inductive step — "if it holds before \( n \), it holds at \( n \)". In strong induction, the step may assume \( P(k) \) for ALL earlier values \( k \) (start \( \le k < n \)), not just for \( n-1 \). Stamp (postage) problems are the classic use.

Problem: Prove that every postage amount \( n \ge 56 \) cents can be formed using only 8-cent and 9-cent stamps.

Base cases — we need one full block of 8 numbers, from 56 to 63:

  • \( 56 = 7 \times 8 \),   \( 57 = 6 \times 8 + 9 \),   \( 58 = 5 \times 8 + 2 \times 9 \),   \( 59 = 4 \times 8 + 3 \times 9 \)
  • \( 60 = 3 \times 8 + 4 \times 9 \),   \( 61 = 2 \times 8 + 5 \times 9 \),   \( 62 = 8 + 6 \times 9 \),   \( 63 = 7 \times 9 \)

Inductive step: take any \( n \ge 64 \). Then \( n - 8 \ge 56 \), so by the strong induction hypothesis \( n - 8 \) can already be formed. Add one more 8-cent stamp to that formation — now we have \( n \). Done: the statement holds for every \( n \ge 56 \).

Mathematical induction দিয়ে কোনো statement \( P(n) \) একটি start থেকে সব \( n \)-এর জন্য প্রমাণ করা হয়: আগে base case, তারপর inductive step — "\( n \)-এর আগে সত্যি হলে \( n \)-এও সত্যি"। Strong induction-এ step-এর সময় শুধু \( n-1 \) না, আগের সব \( k \)-এর (start \( \le k < n \)) জন্য \( P(k) \) ধরে নেওয়া যায়। Stamp (postage) problem হলো এর classic ব্যবহার।

Problem: প্রমাণ করো, প্রতিটি postage amount \( n \ge 56 \) cent শুধু 8-cent আর 9-cent stamp দিয়ে বানানো যায়।

Base case — 8টি সংখ্যার একটি পুরো block লাগবে, 56 থেকে 63:

  • \( 56 = 7 \times 8 \),   \( 57 = 6 \times 8 + 9 \),   \( 58 = 5 \times 8 + 2 \times 9 \),   \( 59 = 4 \times 8 + 3 \times 9 \)
  • \( 60 = 3 \times 8 + 4 \times 9 \),   \( 61 = 2 \times 8 + 5 \times 9 \),   \( 62 = 8 + 6 \times 9 \),   \( 63 = 7 \times 9 \)

Inductive step: যেকোনো \( n \ge 64 \) নাও। তাহলে \( n - 8 \ge 56 \), তাই strong induction hypothesis অনুযায়ী \( n - 8 \) আগেই বানানো যায়। সেই বানানোর সাথে আরেকটি 8-cent stamp যোগ করো — \( n \) পাওয়া গেল। শেষ: প্রতিটি \( n \ge 56 \)-এর জন্য statement সত্যি।

Real exam (April 2017): BUET asked exactly this proof type — "show that any postage above a given amount can be formed with 8-cent and 9-cent stamps". Two tips: (1) the number of base cases equals the smaller stamp value (here 8 cases), because the step jumps back by 8; (2) for coprime stamp values \( a \) and \( b \), the LARGEST impossible amount is \( ab - a - b \) (here \( 72 - 17 = 55 \)) — that is why the proof starts at 56, and why small amounts like 19 or 20 cannot be formed at all.
Real exam (April 2017): BUET ঠিক এই ধরনের প্রমাণ চেয়েছে — "দেখাও যে একটি নির্দিষ্ট amount-এর উপরের যেকোনো postage 8-cent আর 9-cent stamp দিয়ে বানানো যায়"। দুটি tip: (1) base case-এর সংখ্যা = ছোট stamp-এর মান (এখানে 8টি case), কারণ step পিছনে 8 করে লাফায়; (2) coprime stamp মান \( a \) আর \( b \) হলে সবচেয়ে বড় অসম্ভব amount হলো \( ab - a - b \) (এখানে \( 72 - 17 = 55 \)) — তাই প্রমাণ 56 থেকে শুরু, আর 19 বা 20-এর মতো ছোট amount আদৌ বানানো যায় না।

2. Sets2. Sets

A set is a collection of distinct objects, called elements. Order does not matter, and repeats do not count. We write \( A = \{1, 2, 3\} \), and \( 2 \in A \) means "2 is an element of A".

  • Cardinality \( |A| \): the number of elements. \( |\{1,2,3\}| = 3 \).
  • Subset \( A \subseteq B \): every element of A is also in B.
  • Empty set \( \emptyset \): the set with no elements. \( |\emptyset| = 0 \). It is a subset of every set.
  • Universal set \( U \): the set of everything under discussion.

Set হলো আলাদা আলাদা object-এর একটি collection, object গুলোকে বলে element। Order কোনো ব্যাপার না, আর repeat গণনা হয় না। আমরা লিখি \( A = \{1, 2, 3\} \), আর \( 2 \in A \) মানে "2 হলো A-এর element"।

  • Cardinality \( |A| \): element সংখ্যা। \( |\{1,2,3\}| = 3 \)।
  • Subset \( A \subseteq B \): A-এর প্রতিটি element B-তেও আছে।
  • Empty set \( \emptyset \): কোনো element নেই। \( |\emptyset| = 0 \)। এটি সব set-এর subset।
  • Universal set \( U \): আলোচনার সব কিছুর set।

Set operationsSet operations

OperationSymbolMeaningঅর্থExample with A={1,2,3}, B={3,4}উদাহরণ: A={1,2,3}, B={3,4}
Union\( A \cup B \)in A or B (or both)A বা B (বা দুটোতেই)\( \{1,2,3,4\} \)
Intersection\( A \cap B \)in both A and BA এবং B দুটোতেই\( \{3\} \)
Difference\( A - B \)in A but not in BA-তে আছে কিন্তু B-তে নেই\( \{1,2\} \)
Complement\( \overline{A} \)everything in U not in AU-এর যা A-তে নেইdepends on UU-এর উপর নির্ভর করে
Symmetric difference\( A \oplus B \)in exactly one of themঠিক একটিতে আছে\( \{1,2,4\} \)
Venn diagram showing the intersection of two sets A and B
Venn diagram: the shaded middle part is \( A \cap B \), the elements in both sets.Venn diagram: মাঝের shaded অংশটি \( A \cap B \), অর্থাৎ দুই set-এই থাকা element গুলো।

De Morgan's laws work for sets too: \( \overline{A \cup B} = \overline{A} \cap \overline{B} \) and \( \overline{A \cap B} = \overline{A} \cup \overline{B} \). This is the same idea as in logic — union acts like OR, intersection acts like AND.

De Morgan's law set-এর জন্যও কাজ করে: \( \overline{A \cup B} = \overline{A} \cap \overline{B} \) এবং \( \overline{A \cap B} = \overline{A} \cup \overline{B} \)। Logic-এর মতোই — union হলো OR-এর মতো, intersection হলো AND-এর মতো।

Power setPower set

The power set \( P(S) \) is the set of ALL subsets of S, including \( \emptyset \) and S itself.

Power set \( P(S) \) হলো S-এর সব subset-এর set, যার মধ্যে \( \emptyset \) এবং S নিজেও আছে।

\[ |S| = n \implies |P(S)| = 2^n \]
Example: \( S = \{a, b\} \). Then \( P(S) = \{\emptyset, \{a\}, \{b\}, \{a,b\}\} \). Count: \( 2^2 = 4 \). Why \( 2^n \)? Each element has 2 choices: in the subset, or not in it. So \( 2 \times 2 \times \cdots \times 2 = 2^n \).
Example: \( S = \{a, b\} \)। তাহলে \( P(S) = \{\emptyset, \{a\}, \{b\}, \{a,b\}\} \)। সংখ্যা: \( 2^2 = 4 \)। কেন \( 2^n \)? প্রতিটি element-এর 2টি choice: subset-এ থাকবে, অথবা থাকবে না। তাই \( 2 \times 2 \times \cdots \times 2 = 2^n \)।

Cartesian productCartesian product

\( A \times B \) is the set of all ordered pairs \( (a, b) \) where \( a \in A \) and \( b \in B \). Order matters here: \( (1,2) \ne (2,1) \).

\( A \times B \) হলো সব ordered pair \( (a, b) \)-এর set যেখানে \( a \in A \) এবং \( b \in B \)। এখানে order গুরুত্বপূর্ণ: \( (1,2) \ne (2,1) \)।

\[ |A \times B| = |A| \cdot |B| \]
Example: \( A = \{1,2\} \), \( B = \{x, y, z\} \). Then \( A \times B = \{(1,x),(1,y),(1,z),(2,x),(2,y),(2,z)\} \) and \( |A \times B| = 2 \times 3 = 6 \).
Example: \( A = \{1,2\} \), \( B = \{x, y, z\} \)। তাহলে \( A \times B = \{(1,x),(1,y),(1,z),(2,x),(2,y),(2,z)\} \) এবং \( |A \times B| = 2 \times 3 = 6 \)।

Inclusion-exclusion principleInclusion-exclusion principle

If we just add \( |A| + |B| \), the elements in both sets get counted twice. So we subtract the overlap once:

শুধু \( |A| + |B| \) যোগ করলে, দুই set-এই থাকা element গুলো দুইবার গোনা হয়। তাই overlap একবার বিয়োগ করি:

\[ |A \cup B| = |A| + |B| - |A \cap B| \] \[ |A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |B \cap C| - |A \cap C| + |A \cap B \cap C| \]
Example (2 sets): In a class of 50 students, 30 like Math, 25 like Physics, and 12 like both. How many like at least one subject?
\( |M \cup P| = 30 + 25 - 12 = 43 \).
Bonus: students who like neither = \( 50 - 43 = 7 \).
Example (2 sets): 50 জনের class-এ 30 জন Math পছন্দ করে, 25 জন Physics, আর 12 জন দুটোই। অন্তত একটি subject পছন্দ করে কতজন?
\( |M \cup P| = 30 + 25 - 12 = 43 \)।
Bonus: কোনোটাই পছন্দ করে না = \( 50 - 43 = 7 \) জন।
Example (3 sets): How many integers from 1 to 100 are divisible by 2, 3, or 5?
\( |A_2| = \lfloor 100/2 \rfloor = 50 \), \( |A_3| = \lfloor 100/3 \rfloor = 33 \), \( |A_5| = \lfloor 100/5 \rfloor = 20 \).
Pairs: divisible by 6: \( \lfloor 100/6 \rfloor = 16 \); by 10: \( \lfloor 100/10 \rfloor = 10 \); by 15: \( \lfloor 100/15 \rfloor = 6 \).
All three (by 30): \( \lfloor 100/30 \rfloor = 3 \).
Answer: \( 50 + 33 + 20 - 16 - 10 - 6 + 3 = 74 \).
Example (3 sets): 1 থেকে 100-এর মধ্যে কতগুলো integer 2, 3, বা 5 দিয়ে divisible?
\( |A_2| = \lfloor 100/2 \rfloor = 50 \), \( |A_3| = \lfloor 100/3 \rfloor = 33 \), \( |A_5| = \lfloor 100/5 \rfloor = 20 \)।
Pair গুলো: 6 দিয়ে divisible: \( \lfloor 100/6 \rfloor = 16 \); 10 দিয়ে: \( \lfloor 100/10 \rfloor = 10 \); 15 দিয়ে: \( \lfloor 100/15 \rfloor = 6 \)।
তিনটি দিয়েই (30 দিয়ে): \( \lfloor 100/30 \rfloor = 3 \)।
উত্তর: \( 50 + 33 + 20 - 16 - 10 - 6 + 3 = 74 \)।
Example (Real exam — October 2018): How many integers from 1 to 100 are NOT divisible by 3, 5, or 7?
Trick: first count the opposite (divisible by at least one), then subtract from 100.
Singles: \( |A| = \lfloor 100/3 \rfloor = 33 \), \( |B| = \lfloor 100/5 \rfloor = 20 \), \( |C| = \lfloor 100/7 \rfloor = 14 \).
Pairs: by 15: \( \lfloor 100/15 \rfloor = 6 \); by 21: \( \lfloor 100/21 \rfloor = 4 \); by 35: \( \lfloor 100/35 \rfloor = 2 \).
All three (by 105): \( \lfloor 100/105 \rfloor = 0 \).
\( |A \cup B \cup C| = 33 + 20 + 14 - 6 - 4 - 2 + 0 = 55 \).
NOT divisible by any of them: \( 100 - 55 = \mathbf{45} \).
Example (Real exam — October 2018): 1 থেকে 100-এর মধ্যে কতগুলো integer 3, 5, বা 7 দিয়ে divisible নয়?
Trick: আগে উল্টোটা গোনো (অন্তত একটি দিয়ে divisible), তারপর 100 থেকে বিয়োগ করো।
Single: \( |A| = \lfloor 100/3 \rfloor = 33 \), \( |B| = \lfloor 100/5 \rfloor = 20 \), \( |C| = \lfloor 100/7 \rfloor = 14 \)।
Pair: 15 দিয়ে: \( \lfloor 100/15 \rfloor = 6 \); 21 দিয়ে: \( \lfloor 100/21 \rfloor = 4 \); 35 দিয়ে: \( \lfloor 100/35 \rfloor = 2 \)।
তিনটি দিয়েই (105 দিয়ে): \( \lfloor 100/105 \rfloor = 0 \)।
\( |A \cup B \cup C| = 33 + 20 + 14 - 6 - 4 - 2 + 0 = 55 \)।
কোনোটা দিয়েই divisible না: \( 100 - 55 = \mathbf{45} \)।
Exam trap: The signs alternate: add singles (+), subtract pairs (−), add the triple (+). Students often forget to ADD back \( |A \cap B \cap C| \) at the end. Also remember: "divisible by 2 and 3" means divisible by 6 (the LCM), not by 5.
Exam trap: Sign গুলো পাল্টায়: single যোগ (+), pair বিয়োগ (−), triple আবার যোগ (+)। শেষে \( |A \cap B \cap C| \) ADD করতে student-রা প্রায়ই ভুলে যায়। আরও মনে রাখো: "2 এবং 3 দিয়ে divisible" মানে 6 দিয়ে divisible (LCM), 5 দিয়ে নয়।

3. Relations and Functions3. Relations এবং Functions

A relation R on a set A is a subset of \( A \times A \). It is just a set of ordered pairs. If \( (a,b) \in R \) we write \( a \, R \, b \) and say "a is related to b".

Example: on \( A = \{1,2,3\} \), the relation "less than" is \( R = \{(1,2), (1,3), (2,3)\} \).

Set A-এর উপর একটি relation R হলো \( A \times A \)-এর একটি subset। এটা শুধু ordered pair-এর একটি set। যদি \( (a,b) \in R \) হয়, আমরা লিখি \( a \, R \, b \) আর বলি "a is related to b"।

উদাহরণ: \( A = \{1,2,3\} \)-এর উপর "less than" relation হলো \( R = \{(1,2), (1,3), (2,3)\} \)।

Properties of relationsRelation-এর properties

PropertyConditionশর্তSimple meaningসহজ অর্থExample that has itযে relation-এ আছে
Reflexive \( \forall a: (a,a) \in R \) everyone relates to itselfপ্রত্যেকে নিজের সাথে related "=", "≤", "divides""=", "≤", "divides"
Symmetric \( (a,b) \in R \implies (b,a) \in R \) works both waysদুই দিকেই কাজ করে "is sibling of", "=""is sibling of", "="
Transitive \( (a,b), (b,c) \in R \implies (a,c) \in R \) chains pass throughchain ধরে এগোয় "<", "≤", "ancestor of""<", "≤", "ancestor of"
Antisymmetric \( (a,b), (b,a) \in R \implies a = b \) both directions only if equalদুই দিক থাকলে অবশ্যই সমান "≤", "⊆", "divides" (on positives)"≤", "⊆", "divides" (positive-এ)
Example: On \( A = \{1,2,3\} \), let \( R = \{(1,1),(2,2),(3,3),(1,2),(2,1)\} \).
Reflexive? Yes — (1,1), (2,2), (3,3) are all there.
Symmetric? Yes — (1,2) is there and (2,1) is there too.
Transitive? Check (1,2) and (2,1): need (1,1) — yes it is there. Check (2,1) and (1,2): need (2,2) — yes. So transitive.
Antisymmetric? No — (1,2) and (2,1) are both in R but \( 1 \ne 2 \).
Example: \( A = \{1,2,3\} \)-এর উপর \( R = \{(1,1),(2,2),(3,3),(1,2),(2,1)\} \) নিই।
Reflexive? হ্যাঁ — (1,1), (2,2), (3,3) সবই আছে।
Symmetric? হ্যাঁ — (1,2) আছে এবং (2,1)-ও আছে।
Transitive? (1,2) আর (2,1) check করি: (1,1) দরকার — আছে। (2,1) আর (1,2): (2,2) দরকার — আছে। তাই transitive।
Antisymmetric? না — (1,2) আর (2,1) দুটোই R-এ আছে কিন্তু \( 1 \ne 2 \)।

Equivalence relationEquivalence relation

A relation that is reflexive + symmetric + transitive is an equivalence relation. It splits the set into disjoint groups called equivalence classes — every element belongs to exactly one class.

যে relation একসাথে reflexive + symmetric + transitive, সেটি একটি equivalence relation। এটি set-কে আলাদা আলাদা group-এ ভাগ করে, যাদের বলে equivalence class — প্রতিটি element ঠিক একটি class-এ থাকে।

Example: On integers, define \( a \, R \, b \) if \( a \equiv b \pmod{3} \) (same remainder when divided by 3).
Reflexive: \( a - a = 0 \) is divisible by 3. ✓
Symmetric: if \( 3 \mid (a-b) \) then \( 3 \mid (b-a) \). ✓
Transitive: if \( 3 \mid (a-b) \) and \( 3 \mid (b-c) \), then \( 3 \mid (a-b)+(b-c) = (a-c) \). ✓
The equivalence classes are: \( [0] = \{\ldots,-3,0,3,6,\ldots\} \), \( [1] = \{\ldots,-2,1,4,7,\ldots\} \), \( [2] = \{\ldots,-1,2,5,8,\ldots\} \). Three classes, no overlap.
Example: Integer-এর উপর define করি \( a \, R \, b \) যদি \( a \equiv b \pmod{3} \) হয় (3 দিয়ে ভাগ করলে remainder একই)।
Reflexive: \( a - a = 0 \), যা 3 দিয়ে divisible। ✓
Symmetric: \( 3 \mid (a-b) \) হলে \( 3 \mid (b-a) \)। ✓
Transitive: \( 3 \mid (a-b) \) এবং \( 3 \mid (b-c) \) হলে, \( 3 \mid (a-b)+(b-c) = (a-c) \)। ✓
Equivalence class গুলো: \( [0] = \{\ldots,-3,0,3,6,\ldots\} \), \( [1] = \{\ldots,-2,1,4,7,\ldots\} \), \( [2] = \{\ldots,-1,2,5,8,\ldots\} \)। তিনটি class, কোনো overlap নেই।

Partial orderPartial order

A relation that is reflexive + antisymmetric + transitive is a partial order. Classic examples: "≤" on numbers, "⊆" on sets, "divides" on positive integers. It is called "partial" because some pairs may not be comparable — for example, under "divides", 4 and 6 are not comparable (4 does not divide 6, and 6 does not divide 4).

যে relation reflexive + antisymmetric + transitive, সেটি একটি partial order। Classic উদাহরণ: number-এ "≤", set-এ "⊆", positive integer-এ "divides"। একে "partial" বলা হয় কারণ কিছু pair comparable না-ও হতে পারে — যেমন "divides"-এর অধীনে 4 আর 6 comparable না (4, 6-কে ভাগ করে না, আবার 6-ও 4-কে করে না)।

Memory trick: Equivalence relation = R + S + T. Partial order = R + A + T. The only difference is the middle letter: Symmetric vs Antisymmetric.
Memory trick: Equivalence relation = R + S + T। Partial order = R + A + T। পার্থক্য শুধু মাঝের letter-এ: Symmetric বনাম Antisymmetric।

Functions: injective, surjective, bijectiveFunctions: injective, surjective, bijective

A function \( f: A \to B \) sends every element of A (domain) to exactly one element of B (codomain).

  • Injective (one-to-one): different inputs give different outputs. \( f(a_1) = f(a_2) \implies a_1 = a_2 \).
  • Surjective (onto): every element of B is hit by at least one input.
  • Bijective: both injective and surjective. Perfect pairing — a bijection has an inverse function \( f^{-1} \).

একটি function \( f: A \to B \), A-এর (domain) প্রতিটি element-কে B-এর (codomain) ঠিক একটি element-এ পাঠায়।

  • Injective (one-to-one): আলাদা input দিলে আলাদা output। \( f(a_1) = f(a_2) \implies a_1 = a_2 \)।
  • Surjective (onto): B-এর প্রতিটি element অন্তত একটি input থেকে আসে।
  • Bijective: injective এবং surjective দুটোই। Perfect জোড়া — bijection-এর একটি inverse function \( f^{-1} \) থাকে।
Example: Take functions on real numbers.
\( f(x) = 2x + 1 \): injective (different x give different results) and surjective (every real y comes from \( x = (y-1)/2 \)). So bijective.
\( f(x) = x^2 \) as \( f: \mathbb{R} \to \mathbb{R} \): NOT injective (\( f(2) = f(-2) = 4 \)) and NOT surjective (nothing maps to −1).
\( f(x) = e^x \) as \( f: \mathbb{R} \to \mathbb{R} \): injective, but not surjective (never gives 0 or negatives).
Example: Real number-এর উপর function নিই।
\( f(x) = 2x + 1 \): injective (আলাদা x-এ আলাদা result) এবং surjective (প্রতিটি real y আসে \( x = (y-1)/2 \) থেকে)। তাই bijective।
\( f(x) = x^2 \), যেখানে \( f: \mathbb{R} \to \mathbb{R} \): injective NOT (\( f(2) = f(-2) = 4 \)) এবং surjective-ও NOT (−1-এ কিছুই map হয় না)।
\( f(x) = e^x \), যেখানে \( f: \mathbb{R} \to \mathbb{R} \): injective, কিন্তু surjective না (কখনো 0 বা negative দেয় না)।

Composition of functionsFunction-এর composition

\( (g \circ f)(x) = g(f(x)) \) — apply f first, then g. Order matters!

\( (g \circ f)(x) = g(f(x)) \) — আগে f apply করো, তারপর g। Order গুরুত্বপূর্ণ!

Example: \( f(x) = x + 1 \), \( g(x) = x^2 \).
\( (g \circ f)(x) = g(x+1) = (x+1)^2 \). At \( x = 2 \): \( 3^2 = 9 \).
\( (f \circ g)(x) = f(x^2) = x^2 + 1 \). At \( x = 2 \): \( 4 + 1 = 5 \).
Different results — so \( g \circ f \ne f \circ g \) in general.
Example: \( f(x) = x + 1 \), \( g(x) = x^2 \)।
\( (g \circ f)(x) = g(x+1) = (x+1)^2 \)। \( x = 2 \) হলে: \( 3^2 = 9 \)।
\( (f \circ g)(x) = f(x^2) = x^2 + 1 \)। \( x = 2 \) হলে: \( 4 + 1 = 5 \)।
ভিন্ন result — তাই সাধারণভাবে \( g \circ f \ne f \circ g \)।

Counting functions between finite setsFinite set-এর মধ্যে function গোনা

Let \( |A| = m \) and \( |B| = n \). Each of the m elements of A independently picks one of n targets.

ধরি \( |A| = m \) এবং \( |B| = n \)। A-এর m টি element-এর প্রত্যেকে স্বাধীনভাবে n টি target থেকে একটি বেছে নেয়।

\[ \text{Total functions } A \to B: \; n^m \qquad \text{Injective: } \; n(n-1)\cdots(n-m+1) = \frac{n!}{(n-m)!} \quad (m \le n) \qquad \text{Bijective: } \; n! \quad (m = n) \]
Example: \( |A| = 3 \), \( |B| = 4 \).
Total functions: \( 4^3 = 64 \).
Injective functions: \( 4 \times 3 \times 2 = 24 \) (first element has 4 choices, next 3, next 2).
Bijective: 0, because sizes differ.
If \( |A| = |B| = 4 \): bijections = \( 4! = 24 \).
Example: \( |A| = 3 \), \( |B| = 4 \)।
মোট function: \( 4^3 = 64 \)।
Injective function: \( 4 \times 3 \times 2 = 24 \) (প্রথম element-এর 4টি choice, পরেরটির 3টি, তারপর 2টি)।
Bijective: 0, কারণ size আলাদা।
যদি \( |A| = |B| = 4 \) হয়: bijection = \( 4! = 24 \)।
Exam tip: If \( m > n \), the number of injective functions is 0 — this is actually the pigeonhole principle (next section). Also remember which base and exponent: functions \( A \to B \) count as \( |B|^{|A|} \), "codomain to the power of domain".
Exam tip: যদি \( m > n \) হয়, injective function-এর সংখ্যা 0 — এটাই আসলে pigeonhole principle (পরের section-এ)। আরও মনে রাখো কোনটা base কোনটা exponent: function \( A \to B \)-এর সংখ্যা \( |B|^{|A|} \), অর্থাৎ "codomain to the power of domain"।

4. Combinatorics (Counting)4. Combinatorics (Counting)

Sum rule and product ruleSum rule এবং product rule

  • Sum rule: if a task can be done in \( m \) ways OR in \( n \) other ways (no overlap), total = \( m + n \).
  • Product rule: if a task has two steps, first step \( m \) ways AND second step \( n \) ways, total = \( m \times n \).

Quick check: "OR" means add, "AND then" means multiply.

  • Sum rule: কোনো কাজ \( m \) ভাবে OR অন্য \( n \) ভাবে করা গেলে (overlap নেই), মোট = \( m + n \)।
  • Product rule: কাজের দুটি step থাকলে, প্রথম step \( m \) ভাবে AND দ্বিতীয় step \( n \) ভাবে, মোট = \( m \times n \)।

সহজ নিয়ম: "OR" মানে যোগ, "AND তারপর" মানে গুণ।

Example: A restaurant has 4 rice dishes and 6 noodle dishes.
Choose one dish (rice OR noodle): \( 4 + 6 = 10 \) ways.
Choose one rice AND one noodle: \( 4 \times 6 = 24 \) ways.
Another: how many 3-character passwords use one letter (26) then two digits (10 each)? \( 26 \times 10 \times 10 = 2600 \).
Example: একটি restaurant-এ 4টি rice dish আর 6টি noodle dish আছে।
একটি dish বাছাই (rice OR noodle): \( 4 + 6 = 10 \) ভাবে।
একটি rice AND একটি noodle বাছাই: \( 4 \times 6 = 24 \) ভাবে।
আরেকটি: একটি letter (26) তারপর দুটি digit (প্রতিটি 10) দিয়ে কতগুলো 3-character password হয়? \( 26 \times 10 \times 10 = 2600 \)।

Permutations and combinationsPermutations এবং combinations

Permutation = arrangement, order matters. Combination = selection, order does not matter.

Permutation = সাজানো, order গুরুত্বপূর্ণ। Combination = বাছাই, order গুরুত্বপূর্ণ না।

\[ P(n, r) = \frac{n!}{(n-r)!} \qquad\qquad \binom{n}{r} = C(n, r) = \frac{n!}{r!(n-r)!} \qquad\qquad \binom{n}{r} = \binom{n}{n-r} \]
Example: From 5 students, pick a chairman and a secretary (different posts, order matters): \( P(5,2) = 5 \times 4 = 20 \). Pick just 2 members for a team (order does not matter): \( \binom{5}{2} = \frac{5 \times 4}{2} = 10 \). Notice: \( P(5,2) = \binom{5}{2} \times 2! \) — each combination can be ordered in \( 2! \) ways.
Example: 5 জন student থেকে একজন chairman আর একজন secretary বাছাই (আলাদা পদ, order গুরুত্বপূর্ণ): \( P(5,2) = 5 \times 4 = 20 \)। শুধু 2 জন team member বাছাই (order গুরুত্বপূর্ণ না): \( \binom{5}{2} = \frac{5 \times 4}{2} = 10 \)। লক্ষ করো: \( P(5,2) = \binom{5}{2} \times 2! \) — প্রতিটি combination-কে \( 2! \) ভাবে সাজানো যায়।

Arranging letters of a word (repetition inside)শব্দের letter সাজানো (ভিতরে repetition)

If a word has \( n \) letters where one letter repeats \( n_1 \) times, another \( n_2 \) times, and so on, the number of distinct arrangements is:

যদি একটি শব্দে \( n \) টি letter থাকে যেখানে একটি letter \( n_1 \) বার, আরেকটি \( n_2 \) বার repeat হয়, তাহলে distinct arrangement-এর সংখ্যা:

\[ \frac{n!}{n_1! \, n_2! \cdots n_k!} \]
Example: Arrangements of "SUCCESS". It has 7 letters: S appears 3 times, C appears 2 times, U once, E once. \[ \frac{7!}{3! \, 2!} = \frac{5040}{6 \times 2} = 420 \] Harder classic: "MISSISSIPPI" has 11 letters (I×4, S×4, P×2, M×1): \( \frac{11!}{4! \, 4! \, 2!} = 34650 \).
Example: "SUCCESS"-এর arrangement। এতে 7টি letter: S আছে 3 বার, C আছে 2 বার, U একবার, E একবার। \[ \frac{7!}{3! \, 2!} = \frac{5040}{6 \times 2} = 420 \] কঠিন classic: "MISSISSIPPI"-তে 11টি letter (I×4, S×4, P×2, M×1): \( \frac{11!}{4! \, 4! \, 2!} = 34650 \)।

Committee selection problemsCommittee selection problem

Example: From 6 men and 4 women, form a committee of 5 with exactly 2 women.
Choose 2 women: \( \binom{4}{2} = 6 \). Choose 3 men: \( \binom{6}{3} = 20 \).
Product rule: \( 6 \times 20 = 120 \) committees.
Variation — "at least 1 woman": easier by complement. All committees: \( \binom{10}{5} = 252 \). Committees with 0 women (all men): \( \binom{6}{5} = 6 \). Answer: \( 252 - 6 = 246 \).
Example: 6 জন পুরুষ আর 4 জন নারী থেকে 5 জনের committee, যেখানে ঠিক 2 জন নারী।
2 জন নারী বাছাই: \( \binom{4}{2} = 6 \)। 3 জন পুরুষ বাছাই: \( \binom{6}{3} = 20 \)।
Product rule: \( 6 \times 20 = 120 \) টি committee।
Variation — "অন্তত 1 জন নারী": complement দিয়ে সহজ। সব committee: \( \binom{10}{5} = 252 \)। 0 নারীর committee (সব পুরুষ): \( \binom{6}{5} = 6 \)। উত্তর: \( 252 - 6 = 246 \)।

Pigeonhole principlePigeonhole principle

If you put more than \( n \) pigeons into \( n \) holes, some hole gets at least 2 pigeons. General form: with \( N \) objects in \( k \) boxes, some box has at least \( \lceil N/k \rceil \) objects.

\( n \) টি hole-এ \( n \)-এর বেশি pigeon রাখলে, কোনো একটি hole-এ অন্তত 2টি pigeon পড়বেই। General form: \( k \) টি box-এ \( N \) টি object রাখলে, কোনো box-এ অন্তত \( \lceil N/k \rceil \) টি object থাকে।

Example: In any group of 13 people, at least 2 share a birth month — 13 people (pigeons), 12 months (holes).
Another: how many people do we need so that at least 5 were born on the same weekday? Boxes = 7 days. We need \( \lceil N/7 \rceil \ge 5 \), so \( N \ge 4 \times 7 + 1 = 29 \) people.
Example: যেকোনো 13 জন মানুষের group-এ অন্তত 2 জনের birth month একই — 13 জন (pigeon), 12 মাস (hole)।
আরেকটি: কত জন মানুষ লাগবে যেন অন্তত 5 জন একই weekday-তে জন্মায়? Box = 7 দিন। দরকার \( \lceil N/7 \rceil \ge 5 \), তাই \( N \ge 4 \times 7 + 1 = 29 \) জন।

Erdős–Szekeres theorem — pigeonhole power-up (Real Exam!)Erdős–Szekeres theorem — pigeonhole power-up (Real Exam!)

Theorem (Erdős–Szekeres): any sequence of more than \( (r-1)(s-1) \) DISTINCT numbers contains an increasing subsequence of length \( r \) OR a decreasing subsequence of length \( s \). (A subsequence keeps the original order but may skip elements.)

Proof sketch (pigeonhole with label pairs):

  1. Give every position \( i \) a label pair \( (x_i, y_i) \): \( x_i \) = length of the longest increasing subsequence ENDING at \( i \), and \( y_i \) = length of the longest decreasing subsequence ending at \( i \).
  2. Suppose (for contradiction) there is no increasing subsequence of length \( r \) and no decreasing one of length \( s \). Then every \( x_i \le r-1 \) and every \( y_i \le s-1 \). So there are at most \( (r-1)(s-1) \) possible label pairs — these are the pigeonholes.
  3. We have more than \( (r-1)(s-1) \) elements (the pigeons), so two positions \( i < j \) must share the SAME label pair. But that is impossible: if \( a_i < a_j \), we can extend the increasing subsequence, so \( x_j \ge x_i + 1 \); if \( a_i > a_j \), then \( y_j \ge y_i + 1 \). Either way the two pairs differ. Contradiction — so a long subsequence must exist.

Theorem (Erdős–Szekeres): \( (r-1)(s-1) \)-এর বেশি DISTINCT সংখ্যার যেকোনো sequence-এ থাকবে length \( r \)-এর একটি increasing subsequence OR length \( s \)-এর একটি decreasing subsequence। (Subsequence মূল order ঠিক রাখে, কিন্তু মাঝের element বাদ দিতে পারে।)

Proof sketch (label pair দিয়ে pigeonhole):

  1. প্রতিটি position \( i \)-কে একটি label pair \( (x_i, y_i) \) দাও: \( x_i \) = \( i \)-তে END হওয়া longest increasing subsequence-এর length, আর \( y_i \) = \( i \)-তে end হওয়া longest decreasing subsequence-এর length।
  2. ধরো (contradiction-এর জন্য) length \( r \)-এর কোনো increasing subsequence নেই এবং length \( s \)-এর কোনো decreasing subsequence নেই। তাহলে প্রতিটি \( x_i \le r-1 \) এবং প্রতিটি \( y_i \le s-1 \)। তাই সম্ভাব্য label pair সর্বোচ্চ \( (r-1)(s-1) \) টি — এগুলোই pigeonhole।
  3. আমাদের element \( (r-1)(s-1) \)-এর বেশি (এরাই pigeon), তাই দুটি position \( i < j \)-এর label pair একই হতে হবে। কিন্তু সেটা অসম্ভব: যদি \( a_i < a_j \) হয়, increasing subsequence-টা বাড়ানো যায়, তাই \( x_j \ge x_i + 1 \); যদি \( a_i > a_j \) হয়, তাহলে \( y_j \ge y_i + 1 \)। দুই ক্ষেত্রেই pair দুটি আলাদা। Contradiction — তাই লম্বা subsequence থাকতেই হবে।
Example (Real exam — October 2017): 50 students of different heights stand in a line. Show that some 8 of them (keeping their order in the line) have increasing heights or decreasing heights.
Take \( r = s = 8 \). Then \( (r-1)(s-1) = 7 \times 7 = 49 \).
We have \( 50 > 49 \) students, so by Erdős–Szekeres there is an increasing subsequence of length 8 OR a decreasing subsequence of length 8. Done.
Example (Real exam — October 2017): ভিন্ন ভিন্ন height-এর 50 জন student এক লাইনে দাঁড়িয়ে। দেখাও যে তাদের মধ্যে কোনো 8 জনের (লাইনের order ঠিক রেখে) height increasing অথবা decreasing।
নাও \( r = s = 8 \)। তাহলে \( (r-1)(s-1) = 7 \times 7 = 49 \)।
আমাদের student \( 50 > 49 \) জন, তাই Erdős–Szekeres অনুযায়ী length 8-এর একটি increasing subsequence OR length 8-এর একটি decreasing subsequence আছে। শেষ।
Memory trick: "more than \( n^2 \) numbers → a monotone (increasing or decreasing) subsequence of length \( n+1 \)". For length 8 you need more than \( 7^2 = 49 \) numbers — exactly why the exam chose 50 students.
Memory trick: "\( n^2 \)-এর বেশি সংখ্যা → length \( n+1 \)-এর একটি monotone (increasing বা decreasing) subsequence"। Length 8-এর জন্য দরকার \( 7^2 = 49 \)-এর বেশি সংখ্যা — ঠিক এই কারণেই exam-এ 50 জন student নেওয়া হয়েছে।

Binomial theoremBinomial theorem

\[ (x + y)^n = \sum_{r=0}^{n} \binom{n}{r} x^{n-r} y^r \qquad\qquad \sum_{r=0}^{n} \binom{n}{r} = 2^n \]
Example: Find the coefficient of \( x^3 \) in \( (2 + x)^5 \).
General term: \( \binom{5}{r} 2^{5-r} x^r \). We need \( r = 3 \):
\( \binom{5}{3} \cdot 2^{2} = 10 \times 4 = 40 \). So the term is \( 40x^3 \).
Also useful: setting \( x = y = 1 \) in the theorem gives \( 2^n = \sum \binom{n}{r} \) — the total number of subsets again!
Example: \( (2 + x)^5 \)-এ \( x^3 \)-এর coefficient বের করো।
General term: \( \binom{5}{r} 2^{5-r} x^r \)। দরকার \( r = 3 \):
\( \binom{5}{3} \cdot 2^{2} = 10 \times 4 = 40 \)। তাই term-টি \( 40x^3 \)।
আরও দরকারি: theorem-এ \( x = y = 1 \) বসালে পাই \( 2^n = \sum \binom{n}{r} \) — আবার সেই মোট subset সংখ্যা!

Counting with repetitionRepetition সহ counting

Two "repetition allowed" formulas:

  • Permutation with repetition: pick \( r \) items from \( n \) types, order matters, repeats allowed: \( n^r \).
  • Combination with repetition (stars and bars): pick \( r \) items from \( n \) types, order does not matter, repeats allowed: \( \binom{n + r - 1}{r} \).

দুটি "repetition allowed" formula:

  • Permutation with repetition: \( n \) ধরনের জিনিস থেকে \( r \) টি বাছাই, order গুরুত্বপূর্ণ, repeat allowed: \( n^r \)।
  • Combination with repetition (stars and bars): \( n \) ধরনের জিনিস থেকে \( r \) টি বাছাই, order গুরুত্বপূর্ণ না, repeat allowed: \( \binom{n + r - 1}{r} \)।
Example: A shop sells 3 flavors of ice cream. You buy 5 scoops (flavors can repeat, order does not matter). Ways: \[ \binom{3 + 5 - 1}{5} = \binom{7}{5} = \binom{7}{2} = 21 \] Same formula counts solutions of \( x_1 + x_2 + x_3 = 5 \) with each \( x_i \ge 0 \): also 21.
Example: একটি দোকানে 3 flavor-এর ice cream আছে। তুমি 5 scoop কিনবে (flavor repeat হতে পারে, order গুরুত্বপূর্ণ না)। উপায়: \[ \binom{3 + 5 - 1}{5} = \binom{7}{5} = \binom{7}{2} = 21 \] একই formula \( x_1 + x_2 + x_3 = 5 \) (প্রতিটি \( x_i \ge 0 \)) equation-এর solution গোনে: সেটাও 21।
Exam tip: First ask two questions: (1) Does order matter? (2) Is repetition allowed? Order + no repeat → \( P(n,r) \). No order + no repeat → \( \binom{n}{r} \). Order + repeat → \( n^r \). No order + repeat → \( \binom{n+r-1}{r} \).
Exam tip: আগে দুটি প্রশ্ন করো: (1) Order কি গুরুত্বপূর্ণ? (2) Repetition কি allowed? Order + repeat নেই → \( P(n,r) \)। Order নেই + repeat নেই → \( \binom{n}{r} \)। Order + repeat → \( n^r \)। Order নেই + repeat → \( \binom{n+r-1}{r} \)।

5. Recurrence Relations5. Recurrence Relations

A recurrence relation defines a sequence using its previous terms. Example: \( a_n = 2a_{n-1} \) with \( a_0 = 1 \) gives 1, 2, 4, 8, 16, … A recurrence needs initial conditions (base cases) to pin down the sequence.

Setting up a recurrence means asking: "How does the answer for size n depend on smaller sizes?"

Recurrence relation একটি sequence-কে তার আগের term দিয়ে define করে। উদাহরণ: \( a_n = 2a_{n-1} \), \( a_0 = 1 \) হলে পাই 1, 2, 4, 8, 16, … Sequence-টা fix করতে recurrence-এর initial condition (base case) লাগে।

Recurrence বানানো মানে প্রশ্ন করা: "Size n-এর উত্তর ছোট size-এর উপর কীভাবে নির্ভর করে?"

Tower of HanoiTower of Hanoi

Move n disks from peg A to peg C, one disk at a time, never putting a bigger disk on a smaller one. Plan: move the top \( n-1 \) disks to peg B, move the biggest disk to C, then move the \( n-1 \) disks from B to C. So:

n টি disk-কে peg A থেকে peg C-তে নিতে হবে, একবারে একটি disk, বড় disk কখনো ছোট disk-এর উপরে না। Plan: উপরের \( n-1 \) টি disk B-তে নাও, সবচেয়ে বড় disk C-তে নাও, তারপর \( n-1 \) টি disk B থেকে C-তে নাও। তাহলে:

\[ T(n) = 2T(n-1) + 1, \quad T(1) = 1 \qquad \Longrightarrow \qquad T(n) = 2^n - 1 \]
Tower of Hanoi puzzle with wooden disks on three pegs
Tower of Hanoi: moving n disks needs \( 2^n - 1 \) moves. For 8 disks: 255 moves.Tower of Hanoi: n টি disk সরাতে \( 2^n - 1 \) টি move লাগে। 8টি disk হলে: 255 move।
Example (unrolling): Check the formula by expanding:
\( T(n) = 2T(n-1) + 1 = 2(2T(n-2)+1) + 1 = 4T(n-2) + 3 = 8T(n-3) + 7 = \cdots = 2^{k}T(n-k) + 2^{k}-1 \).
Stop at \( k = n-1 \): \( T(n) = 2^{n-1}T(1) + 2^{n-1} - 1 = 2^{n-1} + 2^{n-1} - 1 = 2^n - 1 \). ✓
Quick values: T(1)=1, T(2)=3, T(3)=7, T(4)=15.
Example (unrolling): Expand করে formula check করি:
\( T(n) = 2T(n-1) + 1 = 2(2T(n-2)+1) + 1 = 4T(n-2) + 3 = 8T(n-3) + 7 = \cdots = 2^{k}T(n-k) + 2^{k}-1 \)।
\( k = n-1 \)-তে থামি: \( T(n) = 2^{n-1}T(1) + 2^{n-1} - 1 = 2^{n-1} + 2^{n-1} - 1 = 2^n - 1 \)। ✓
কিছু value: T(1)=1, T(2)=3, T(3)=7, T(4)=15।

Solving linear homogeneous recurrencesLinear homogeneous recurrence solve করা

For a recurrence like \( a_n = c_1 a_{n-1} + c_2 a_{n-2} \), use the characteristic equation method:

  1. Guess \( a_n = r^n \). Substitute to get \( r^2 = c_1 r + c_2 \), i.e. \( r^2 - c_1 r - c_2 = 0 \).
  2. Find the roots \( r_1, r_2 \).
  3. If roots are distinct: \( a_n = \alpha \, r_1^n + \beta \, r_2^n \). If there is a repeated root r: \( a_n = (\alpha + \beta n) r^n \).
  4. Use the initial conditions to find \( \alpha, \beta \).

\( a_n = c_1 a_{n-1} + c_2 a_{n-2} \) ধরনের recurrence-এর জন্য characteristic equation method ব্যবহার করো:

  1. ধরো \( a_n = r^n \)। বসালে পাই \( r^2 = c_1 r + c_2 \), অর্থাৎ \( r^2 - c_1 r - c_2 = 0 \)।
  2. Root গুলো বের করো: \( r_1, r_2 \)।
  3. Root আলাদা হলে: \( a_n = \alpha \, r_1^n + \beta \, r_2^n \)। Root repeated হলে (r): \( a_n = (\alpha + \beta n) r^n \)।
  4. Initial condition দিয়ে \( \alpha, \beta \) বের করো।
Example (full solve): Solve \( a_n = 5a_{n-1} - 6a_{n-2} \), with \( a_0 = 1 \), \( a_1 = 4 \).
Step 1: characteristic equation: \( r^2 - 5r + 6 = 0 \).
Step 2: factor: \( (r-2)(r-3) = 0 \), so \( r_1 = 2 \), \( r_2 = 3 \).
Step 3: general solution: \( a_n = \alpha \cdot 2^n + \beta \cdot 3^n \).
Step 4: use initial conditions:
\( n=0: \alpha + \beta = 1 \).   \( n=1: 2\alpha + 3\beta = 4 \).
From the first: \( \alpha = 1 - \beta \). Substitute: \( 2(1-\beta) + 3\beta = 4 \Rightarrow 2 + \beta = 4 \Rightarrow \beta = 2, \alpha = -1 \).
Answer: \( a_n = -2^n + 2 \cdot 3^n \). Check \( a_2 \): recurrence gives \( 5(4) - 6(1) = 14 \); formula gives \( -4 + 18 = 14 \). ✓
Example (full solve): Solve করো \( a_n = 5a_{n-1} - 6a_{n-2} \), যেখানে \( a_0 = 1 \), \( a_1 = 4 \)।
Step 1: characteristic equation: \( r^2 - 5r + 6 = 0 \)।
Step 2: factor: \( (r-2)(r-3) = 0 \), তাই \( r_1 = 2 \), \( r_2 = 3 \)।
Step 3: general solution: \( a_n = \alpha \cdot 2^n + \beta \cdot 3^n \)।
Step 4: initial condition ব্যবহার:
\( n=0: \alpha + \beta = 1 \)।   \( n=1: 2\alpha + 3\beta = 4 \)।
প্রথমটি থেকে: \( \alpha = 1 - \beta \)। বসাই: \( 2(1-\beta) + 3\beta = 4 \Rightarrow 2 + \beta = 4 \Rightarrow \beta = 2, \alpha = -1 \)।
উত্তর: \( a_n = -2^n + 2 \cdot 3^n \)। \( a_2 \) check: recurrence দেয় \( 5(4) - 6(1) = 14 \); formula দেয় \( -4 + 18 = 14 \)। ✓

Fibonacci and its closed formFibonacci এবং তার closed form

The Fibonacci sequence: \( F_n = F_{n-1} + F_{n-2} \), \( F_0 = 0, F_1 = 1 \): 0, 1, 1, 2, 3, 5, 8, 13, …

Its characteristic equation is \( r^2 - r - 1 = 0 \), with roots \( \varphi = \frac{1+\sqrt{5}}{2} \approx 1.618 \) (the golden ratio) and \( \psi = \frac{1-\sqrt{5}}{2} \approx -0.618 \). Applying the same method gives Binet's formula:

Fibonacci sequence: \( F_n = F_{n-1} + F_{n-2} \), \( F_0 = 0, F_1 = 1 \): 0, 1, 1, 2, 3, 5, 8, 13, …

এর characteristic equation \( r^2 - r - 1 = 0 \), root দুটি \( \varphi = \frac{1+\sqrt{5}}{2} \approx 1.618 \) (golden ratio) এবং \( \psi = \frac{1-\sqrt{5}}{2} \approx -0.618 \)। একই method apply করলে পাই Binet's formula:

\[ F_n = \frac{\varphi^n - \psi^n}{\sqrt{5}} \]

Since \( |\psi| < 1 \), the \( \psi^n \) part shrinks to almost nothing. So \( F_n \approx \varphi^n / \sqrt{5} \) — Fibonacci grows exponentially, and the ratio \( F_{n+1}/F_n \) approaches the golden ratio.

যেহেতু \( |\psi| < 1 \), তাই \( \psi^n \) অংশটা প্রায় শূন্য হয়ে যায়। ফলে \( F_n \approx \varphi^n / \sqrt{5} \) — Fibonacci exponentially বাড়ে, আর \( F_{n+1}/F_n \) ratio golden ratio-র দিকে যায়।

Exam tip: Two recurrence answers worth memorizing: Tower of Hanoi \( \to 2^n - 1 \), and \( a_n = a_{n-1} + n \) type (like counting handshakes) \( \to \) sums such as \( n(n+1)/2 \). For characteristic equations, watch the sign: \( a_n = 5a_{n-1} - 6a_{n-2} \) becomes \( r^2 \mathbf{-} 5r \mathbf{+} 6 = 0 \) — move everything to one side carefully.
Exam tip: দুটি recurrence-এর উত্তর মুখস্থ রাখার মতো: Tower of Hanoi \( \to 2^n - 1 \), আর \( a_n = a_{n-1} + n \) ধরন (যেমন handshake গোনা) \( \to \) \( n(n+1)/2 \)-এর মতো sum। Characteristic equation-এ sign খেয়াল করো: \( a_n = 5a_{n-1} - 6a_{n-2} \) হয়ে যায় \( r^2 \mathbf{-} 5r \mathbf{+} 6 = 0 \) — সাবধানে সব এক পাশে নাও।

6. Graphs and Trees6. Graphs এবং Trees

A graph \( G = (V, E) \) has a set of vertices (nodes) V and a set of edges E connecting pairs of vertices. Key terms:

  • Degree deg(v): number of edges touching vertex v.
  • Path: a sequence of vertices connected by edges, no vertex repeated.
  • Cycle: a path that starts and ends at the same vertex.
  • Connected graph: there is a path between every pair of vertices.
  • Simple graph: no self-loops, no repeated edges.
  • Complete graph \( K_n \): every pair of vertices is connected. It has \( \binom{n}{2} = \frac{n(n-1)}{2} \) edges.

Graph \( G = (V, E) \)-তে থাকে vertex (node)-এর set V আর vertex-এর জোড়া যুক্তকারী edge-এর set E। মূল term গুলো:

  • Degree deg(v): vertex v-কে ছোঁয়া edge-এর সংখ্যা।
  • Path: edge দিয়ে যুক্ত vertex-এর একটি sequence, কোনো vertex repeat হয় না।
  • Cycle: যে path একই vertex-এ শুরু আর শেষ হয়।
  • Connected graph: প্রতিটি vertex জোড়ার মধ্যে path আছে।
  • Simple graph: কোনো self-loop নেই, repeated edge নেই।
  • Complete graph \( K_n \): প্রতিটি vertex জোড়া যুক্ত। এর edge সংখ্যা \( \binom{n}{2} = \frac{n(n-1)}{2} \)।

Handshaking lemmaHandshaking lemma

Every edge touches exactly 2 vertices, so it adds 2 to the total degree:

প্রতিটি edge ঠিক 2টি vertex ছোঁয়, তাই মোট degree-তে 2 যোগ করে:

\[ \sum_{v \in V} \deg(v) = 2|E| \]
Example: A graph has 5 vertices with degrees 2, 3, 3, 4, 4. How many edges?
Sum of degrees = \( 2+3+3+4+4 = 16 \). So \( |E| = 16/2 = 8 \).
Useful corollary: the number of odd-degree vertices is always EVEN. A graph with degrees 1, 2, 3 (sum = 6, ok) is possible; but degrees 1, 1, 1 (sum = 3, odd) is impossible.
Example: একটি graph-এ 5টি vertex, degree গুলো 2, 3, 3, 4, 4। Edge কয়টি?
Degree-র যোগফল = \( 2+3+3+4+4 = 16 \)। তাই \( |E| = 16/2 = 8 \)।
দরকারি corollary: odd-degree vertex-এর সংখ্যা সবসময় EVEN। Degree 1, 2, 3 (যোগফল 6, ঠিক আছে) সম্ভব; কিন্তু degree 1, 1, 1 (যোগফল 3, odd) অসম্ভব।

Euler and Hamiltonian pathsEuler এবং Hamiltonian paths

  • Euler path: uses every EDGE exactly once. Exists in a connected graph iff it has exactly 0 or 2 odd-degree vertices.
  • Euler circuit: Euler path that returns to the start. Exists iff ALL vertices have even degree.
  • Hamiltonian path: visits every VERTEX exactly once. No simple degree condition — checking is hard (NP-complete).

The famous Königsberg bridge problem started graph theory: can you walk crossing each of the 7 bridges exactly once? All 4 land areas have odd degree — more than 2 odd vertices — so Euler proved it is impossible.

  • Euler path: প্রতিটি EDGE ঠিক একবার ব্যবহার করে। Connected graph-এ থাকে iff odd-degree vertex ঠিক 0 বা 2টি।
  • Euler circuit: Euler path যা শুরুতে ফিরে আসে। থাকে iff সব vertex-এর degree even।
  • Hamiltonian path: প্রতিটি VERTEX ঠিক একবার visit করে। কোনো সহজ degree শর্ত নেই — check করা কঠিন (NP-complete)।

বিখ্যাত Königsberg bridge problem থেকেই graph theory শুরু: 7টি bridge-এর প্রতিটি ঠিক একবার পার হয়ে হাঁটা যায় কি? 4টি land area-র সবগুলোর degree odd — 2টির বেশি odd vertex — তাই Euler প্রমাণ করেন এটা অসম্ভব।

Map of Konigsberg showing the seven bridges over the river
The seven bridges of Königsberg. Euler turned this map into a graph and proved the walk is impossible.Königsberg-এর সাতটি bridge। Euler এই map-কে graph বানিয়ে প্রমাণ করেন এই হাঁটা অসম্ভব।

Bipartite graphs and coloringBipartite graphs এবং coloring

A graph is bipartite if its vertices split into two groups, and every edge goes between the groups (never inside a group). Key fact: a graph is bipartite iff it has no odd-length cycle. The complete bipartite graph \( K_{m,n} \) has \( m \times n \) edges.

Graph coloring: assign colors to vertices so that neighbors get different colors. The minimum number of colors needed is the chromatic number \( \chi(G) \). Bipartite = 2-colorable, so \( \chi = 2 \) (if it has at least one edge). For \( K_n \), \( \chi = n \). For a cycle: even cycle needs 2 colors, odd cycle needs 3.

একটি graph bipartite যদি তার vertex দুটি group-এ ভাগ হয়, আর প্রতিটি edge দুই group-এর মাঝে যায় (কখনো group-এর ভিতরে না)। মূল fact: graph bipartite iff কোনো odd-length cycle নেই। Complete bipartite graph \( K_{m,n} \)-এর edge সংখ্যা \( m \times n \)।

Graph coloring: vertex-এ রঙ দাও যেন প্রতিবেশীরা আলাদা রঙ পায়। সর্বনিম্ন যত রঙ লাগে তা হলো chromatic number \( \chi(G) \)। Bipartite = 2-colorable, তাই \( \chi = 2 \) (অন্তত একটি edge থাকলে)। \( K_n \)-এর জন্য \( \chi = n \)। Cycle-এর জন্য: even cycle-এ 2 রঙ, odd cycle-এ 3 রঙ।

a b c x y z Set 1 Set 2
A bipartite graph: every edge goes between Set 1 (blue) and Set 2 (red). Two colors are enough.একটি bipartite graph: প্রতিটি edge Set 1 (নীল) আর Set 2 (লাল)-এর মাঝে যায়। দুটি রঙই যথেষ্ট।

TreesTrees

A tree is a connected graph with NO cycles. Equivalent facts (any one implies the others):

  • A tree with \( n \) vertices has exactly \( n - 1 \) edges.
  • Between any two vertices there is exactly ONE path.
  • Adding any edge creates exactly one cycle; removing any edge disconnects it.

A spanning tree of a connected graph G is a tree that contains all vertices of G. To get one, delete \( |E| - (n-1) \) edges (breaking all cycles). A rooted tree picks one vertex as root; then we can talk about parent, child, leaf (no children), height, and levels.

Tree হলো এমন connected graph যাতে কোনো cycle নেই। Equivalent fact গুলো (একটি হলে বাকিগুলোও হয়):

  • \( n \) vertex-এর tree-তে ঠিক \( n - 1 \) টি edge থাকে।
  • যেকোনো দুটি vertex-এর মাঝে ঠিক একটি path থাকে।
  • যেকোনো edge যোগ করলে ঠিক একটি cycle তৈরি হয়; যেকোনো edge সরালে graph disconnected হয়।

Connected graph G-এর spanning tree হলো এমন একটি tree যাতে G-এর সব vertex আছে। এটি পেতে \( |E| - (n-1) \) টি edge মুছতে হয় (সব cycle ভাঙা)। Rooted tree-তে একটি vertex-কে root ধরা হয়; তখন parent, child, leaf (child নেই), height আর level নিয়ে কথা বলা যায়।

Example: A connected graph has 6 vertices and 9 edges. How many edges must be removed to get a spanning tree?
A spanning tree on 6 vertices has \( 6 - 1 = 5 \) edges. Remove \( 9 - 5 = 4 \) edges.
Another: a tree has 10 vertices. Edges? Always \( 10 - 1 = 9 \). No calculation needed.
Example: একটি connected graph-এ 6টি vertex আর 9টি edge। Spanning tree পেতে কয়টি edge সরাতে হবে?
6 vertex-এর spanning tree-তে \( 6 - 1 = 5 \) টি edge। সরাতে হবে \( 9 - 5 = 4 \) টি।
আরেকটি: একটি tree-তে 10টি vertex। Edge? সবসময় \( 10 - 1 = 9 \)। কোনো হিসাব লাগে না।
Exam tip: Euler = edges, Hamilton = vertices. Remember it as "E for Edge, both start with E is wrong — Euler and Edge both have E". Check Euler conditions by counting odd-degree vertices: 0 odd → circuit, 2 odd → path (start at one odd vertex, end at the other), more than 2 → neither.
Exam tip: Euler = edges, Hamilton = vertices। মনে রাখো: "Euler আর Edge — দুটোতেই E"। Euler-এর শর্ত check করো odd-degree vertex গুনে: 0টি odd → circuit, 2টি odd → path (এক odd vertex-এ শুরু, অন্যটায় শেষ), 2-এর বেশি → কোনোটাই না।

7. Basic Number Theory7. Basic Number Theory

Divisibility and primesDivisibility এবং primes

We say \( a \mid b \) ("a divides b") if \( b = ka \) for some integer k. Example: \( 3 \mid 12 \), but \( 5 \nmid 12 \).

A prime is an integer greater than 1 whose only divisors are 1 and itself: 2, 3, 5, 7, 11, 13, … The number 1 is NOT prime. The fundamental theorem of arithmetic: every integer greater than 1 has a unique prime factorization. Example: \( 360 = 2^3 \times 3^2 \times 5 \).

Quick primality check for small n: test divisibility by primes up to \( \sqrt{n} \). For 97: \( \sqrt{97} \approx 9.8 \), test 2, 3, 5, 7 — none divide it, so 97 is prime.

আমরা বলি \( a \mid b \) ("a divides b") যদি কোনো integer k-এর জন্য \( b = ka \) হয়। উদাহরণ: \( 3 \mid 12 \), কিন্তু \( 5 \nmid 12 \)।

Prime হলো 1-এর চেয়ে বড় integer যার divisor শুধু 1 আর সে নিজে: 2, 3, 5, 7, 11, 13, … সংখ্যা 1 prime NOT। Fundamental theorem of arithmetic: 1-এর চেয়ে বড় প্রতিটি integer-এর একটি unique prime factorization আছে। উদাহরণ: \( 360 = 2^3 \times 3^2 \times 5 \)।

ছোট n-এর জন্য দ্রুত primality check: \( \sqrt{n} \) পর্যন্ত prime দিয়ে ভাগ করে দেখো। 97-এর জন্য: \( \sqrt{97} \approx 9.8 \), তাই 2, 3, 5, 7 test করো — কোনোটাই ভাগ করে না, তাই 97 prime।

GCD, LCM, and the Euclidean algorithmGCD, LCM এবং Euclidean algorithm

GCD (greatest common divisor) is the largest number dividing both a and b. LCM (least common multiple) is the smallest positive number both divide. They connect by a beautiful identity:

GCD (greatest common divisor) হলো সবচেয়ে বড় সংখ্যা যা a আর b দুটোকেই ভাগ করে। LCM (least common multiple) হলো সবচেয়ে ছোট positive সংখ্যা যাকে দুটোই ভাগ করে। এদের মধ্যে সুন্দর সম্পর্ক:

\[ \gcd(a, b) \times \text{lcm}(a, b) = a \times b \]

The Euclidean algorithm finds gcd fast: replace the bigger number by its remainder when divided by the smaller. Repeat until the remainder is 0. The last non-zero remainder is the gcd.

Euclidean algorithm দ্রুত gcd বের করে: বড় সংখ্যাকে ছোট সংখ্যা দিয়ে ভাগের remainder দিয়ে বদলাও। Remainder 0 না হওয়া পর্যন্ত repeat করো। শেষ non-zero remainder-টিই gcd।

Example (worked): Find \( \gcd(252, 198) \).
\( 252 = 1 \times 198 + 54 \)
\( 198 = 3 \times 54 + 36 \)
\( 54 = 1 \times 36 + 18 \)
\( 36 = 2 \times 18 + 0 \) ← remainder 0, stop.
So \( \gcd(252, 198) = 18 \). And \( \text{lcm} = \frac{252 \times 198}{18} = 2772 \).
Example (worked): \( \gcd(252, 198) \) বের করো।
\( 252 = 1 \times 198 + 54 \)
\( 198 = 3 \times 54 + 36 \)
\( 54 = 1 \times 36 + 18 \)
\( 36 = 2 \times 18 + 0 \) ← remainder 0, থামো।
তাই \( \gcd(252, 198) = 18 \)। আর \( \text{lcm} = \frac{252 \times 198}{18} = 2772 \)।

Modular arithmetic and congruencesModular arithmetic এবং congruences

\( a \equiv b \pmod{m} \) means m divides \( a - b \) — in other words, a and b leave the same remainder when divided by m. Example: \( 17 \equiv 2 \pmod{5} \) because both leave remainder 2.

Congruences behave nicely with + and ×: if \( a \equiv b \) and \( c \equiv d \pmod m \), then \( a + c \equiv b + d \) and \( ac \equiv bd \pmod m \). This lets us reduce numbers BEFORE multiplying — the key trick for big powers.

\( a \equiv b \pmod{m} \) মানে m, \( a - b \)-কে ভাগ করে — অর্থাৎ a আর b-কে m দিয়ে ভাগ করলে remainder একই। উদাহরণ: \( 17 \equiv 2 \pmod{5} \), কারণ দুটোরই remainder 2।

Congruence + আর ×-এর সাথে সুন্দর আচরণ করে: যদি \( a \equiv b \) এবং \( c \equiv d \pmod m \), তাহলে \( a + c \equiv b + d \) এবং \( ac \equiv bd \pmod m \)। এতে গুণ করার আগেই সংখ্যা ছোট করা যায় — বড় power-এর জন্য মূল trick।

Example: What is \( 123 \times 457 \bmod 10 \)?
Reduce first: \( 123 \equiv 3 \), \( 457 \equiv 7 \pmod{10} \).
So the answer is \( 3 \times 7 = 21 \equiv 1 \pmod{10} \). (This is just the last digit trick.)
Example: \( 123 \times 457 \bmod 10 \) কত?
আগে ছোট করো: \( 123 \equiv 3 \), \( 457 \equiv 7 \pmod{10} \)।
তাই উত্তর \( 3 \times 7 = 21 \equiv 1 \pmod{10} \)। (এটা আসলে last digit-এর trick।)

Modular exponentiationModular exponentiation

To compute \( a^n \bmod m \) for big n, look for a repeating pattern of powers, or use repeated squaring.

বড় n-এর জন্য \( a^n \bmod m \) বের করতে power-এর repeating pattern খোঁজো, অথবা repeated squaring ব্যবহার করো।

Example (pattern method): Find \( 3^{100} \bmod 7 \).
Powers of 3 mod 7: \( 3^1 = 3, \; 3^2 = 2, \; 3^3 = 6, \; 3^4 = 4, \; 3^5 = 5, \; 3^6 = 1 \). The pattern repeats every 6 steps.
\( 100 = 6 \times 16 + 4 \), so \( 3^{100} = (3^6)^{16} \cdot 3^4 \equiv 1^{16} \cdot 4 = 4 \pmod 7 \).
Answer: 4.
Example (pattern method): \( 3^{100} \bmod 7 \) বের করো।
3-এর power mod 7: \( 3^1 = 3, \; 3^2 = 2, \; 3^3 = 6, \; 3^4 = 4, \; 3^5 = 5, \; 3^6 = 1 \)। Pattern প্রতি 6 step-এ repeat হয়।
\( 100 = 6 \times 16 + 4 \), তাই \( 3^{100} = (3^6)^{16} \cdot 3^4 \equiv 1^{16} \cdot 4 = 4 \pmod 7 \)।
উত্তর: 4।
Example (repeated squaring): Find \( 2^{10} \bmod 1000 \) the fast way.
\( 2^2 = 4, \; 2^4 = 4^2 = 16, \; 2^8 = 16^2 = 256 \).
\( 2^{10} = 2^8 \cdot 2^2 = 256 \times 4 = 1024 \equiv 24 \pmod{1000} \).
Each step squares the previous result — only \( O(\log n) \) multiplications. Computers use exactly this trick in cryptography (RSA).
Example (repeated squaring): দ্রুত উপায়ে \( 2^{10} \bmod 1000 \) বের করো।
\( 2^2 = 4, \; 2^4 = 4^2 = 16, \; 2^8 = 16^2 = 256 \)।
\( 2^{10} = 2^8 \cdot 2^2 = 256 \times 4 = 1024 \equiv 24 \pmod{1000} \)।
প্রতিটি step আগের result-কে square করে — মাত্র \( O(\log n) \) টি গুণ। Cryptography-তে (RSA) computer ঠিক এই trick-ই ব্যবহার করে।
Exam tip: "Find the last digit of \( a^n \)" means \( a^n \bmod 10 \). "Find the remainder when divided by m" means mod m. Almost always the powers repeat in a short cycle — find the cycle length first, then divide the exponent by it and use the remainder.
Exam tip: "\( a^n \)-এর last digit বের করো" মানে \( a^n \bmod 10 \)। "m দিয়ে ভাগ করলে remainder কত" মানে mod m। প্রায় সবসময় power গুলো ছোট cycle-এ repeat হয় — আগে cycle length বের করো, তারপর exponent-কে সেটা দিয়ে ভাগ করে remainder ব্যবহার করো।

Practice Questions (Admission Style)Practice Questions (Admission Style)

Q1. If \( p \) is false and \( q \) is true, what is the truth value of \( p \rightarrow q \)?
  • (a) True
  • (b) False
  • (c) Cannot be determined
  • (d) Both true and false
Q1. যদি \( p \) false এবং \( q \) true হয়, \( p \rightarrow q \)-এর truth value কী?
  • (a) True
  • (b) False
  • (c) নির্ণয় করা যায় না
  • (d) True এবং false দুটোই
Show Answerউত্তর দেখুন
Answer: (a) — An implication is false ONLY when the hypothesis is true and the conclusion is false. Here \( p \) is false, so \( p \rightarrow q \) is automatically true ("vacuously true"), whatever \( q \) is.
Answer: (a) — Implication শুধু তখনই false যখন hypothesis true আর conclusion false। এখানে \( p \) false, তাই \( p \rightarrow q \) automatically true ("vacuously true"), \( q \) যা-ই হোক।
Q2. A set S has 6 elements. How many elements are in the power set \( P(S) \)?
  • (a) 6
  • (b) 36
  • (c) 64
  • (d) 128
Q2. Set S-এ 6টি element আছে। Power set \( P(S) \)-এ কয়টি element?
  • (a) 6
  • (b) 36
  • (c) 64
  • (d) 128
Show Answerউত্তর দেখুন
Answer: (c) — \( |P(S)| = 2^n = 2^6 = 64 \). Each element is either in a subset or not: 2 choices each, 6 elements, so \( 2^6 \).
Answer: (c) — \( |P(S)| = 2^n = 2^6 = 64 \)। প্রতিটি element হয় subset-এ থাকে, নয় থাকে না: প্রতিটির 2টি choice, 6টি element, তাই \( 2^6 \)।
Q3. Which is logically equivalent to \( \neg(p \lor q) \)?
  • (a) \( \neg p \lor \neg q \)
  • (b) \( \neg p \land \neg q \)
  • (c) \( p \land q \)
  • (d) \( \neg p \rightarrow q \)
Q3. \( \neg(p \lor q) \)-এর logically equivalent কোনটি?
  • (a) \( \neg p \lor \neg q \)
  • (b) \( \neg p \land \neg q \)
  • (c) \( p \land q \)
  • (d) \( \neg p \rightarrow q \)
Show Answerউত্তর দেখুন
Answer: (b) — De Morgan's law: negation of OR becomes AND of negations. "Not (p or q)" means both fail: not p AND not q. Option (a) is the wrong pairing — that equals \( \neg(p \land q) \).
Answer: (b) — De Morgan's law: OR-এর negation হয় negation-দের AND। "Not (p or q)" মানে দুটোই fail: not p AND not q। Option (a) ভুল জোড়া — সেটা \( \neg(p \land q) \)-এর সমান।
Q4. (Written) Write the converse, inverse, and contrapositive of: "If a number is divisible by 6, then it is divisible by 3." State which ones are true.
Q4. (Written) এই statement-এর converse, inverse এবং contrapositive লেখো: "যদি একটি সংখ্যা 6 দিয়ে divisible হয়, তবে এটি 3 দিয়ে divisible।" কোনগুলো true তা বলো।
Show Answerউত্তর দেখুন
Answer:
Original \( p \rightarrow q \): true (6 = 2×3, so any multiple of 6 is a multiple of 3).
Converse ( \( q \rightarrow p \) ): "If divisible by 3, then divisible by 6." FALSE — counterexample: 9 is divisible by 3 but not by 6.
Inverse ( \( \neg p \rightarrow \neg q \) ): "If not divisible by 6, then not divisible by 3." FALSE — same counterexample: 9.
Contrapositive ( \( \neg q \rightarrow \neg p \) ): "If not divisible by 3, then not divisible by 6." TRUE — it is equivalent to the original.
Answer:
মূল \( p \rightarrow q \): true (6 = 2×3, তাই 6-এর যেকোনো multiple 3-এরও multiple)।
Converse ( \( q \rightarrow p \) ): "3 দিয়ে divisible হলে 6 দিয়ে divisible।" FALSE — counterexample: 9, যা 3 দিয়ে divisible কিন্তু 6 দিয়ে নয়।
Inverse ( \( \neg p \rightarrow \neg q \) ): "6 দিয়ে divisible না হলে 3 দিয়েও না।" FALSE — একই counterexample: 9।
Contrapositive ( \( \neg q \rightarrow \neg p \) ): "3 দিয়ে divisible না হলে 6 দিয়েও না।" TRUE — এটি মূল statement-এর equivalent।
Q5. In a class, 40 students play cricket, 30 play football, and 15 play both. How many students play at least one game?
  • (a) 70
  • (b) 55
  • (c) 85
  • (d) 45
Q5. একটি class-এ 40 জন cricket খেলে, 30 জন football, আর 15 জন দুটোই। অন্তত একটি খেলা খেলে কতজন?
  • (a) 70
  • (b) 55
  • (c) 85
  • (d) 45
Show Answerউত্তর দেখুন
Answer: (b) — Inclusion-exclusion: \( |C \cup F| = 40 + 30 - 15 = 55 \). Adding 40 + 30 counts the 15 both-players twice, so subtract once.
Answer: (b) — Inclusion-exclusion: \( |C \cup F| = 40 + 30 - 15 = 55 \)। 40 + 30 যোগ করলে দুটোই খেলা 15 জন দুইবার গোনা হয়, তাই একবার বিয়োগ।
Q6. (Written) How many integers from 1 to 300 are divisible by 3, 5, or 7?
Q6. (Written) 1 থেকে 300-এর মধ্যে কতগুলো integer 3, 5, বা 7 দিয়ে divisible?
Show Answerউত্তর দেখুন
Answer: 162
Singles: \( \lfloor 300/3 \rfloor = 100 \), \( \lfloor 300/5 \rfloor = 60 \), \( \lfloor 300/7 \rfloor = 42 \).
Pairs: \( \lfloor 300/15 \rfloor = 20 \), \( \lfloor 300/21 \rfloor = 14 \), \( \lfloor 300/35 \rfloor = 8 \).
Triple: \( \lfloor 300/105 \rfloor = 2 \).
Inclusion-exclusion: \( 100 + 60 + 42 - 20 - 14 - 8 + 2 = 162 \).
Answer: 162
Single: \( \lfloor 300/3 \rfloor = 100 \), \( \lfloor 300/5 \rfloor = 60 \), \( \lfloor 300/7 \rfloor = 42 \)।
Pair: \( \lfloor 300/15 \rfloor = 20 \), \( \lfloor 300/21 \rfloor = 14 \), \( \lfloor 300/35 \rfloor = 8 \)।
Triple: \( \lfloor 300/105 \rfloor = 2 \)।
Inclusion-exclusion: \( 100 + 60 + 42 - 20 - 14 - 8 + 2 = 162 \)।
Q7. The relation \( a \equiv b \pmod 5 \) on integers is:
  • (a) A partial order
  • (b) An equivalence relation
  • (c) Antisymmetric
  • (d) Not transitive
Q7. Integer-এর উপর \( a \equiv b \pmod 5 \) relation-টি হলো:
  • (a) একটি partial order
  • (b) একটি equivalence relation
  • (c) Antisymmetric
  • (d) Transitive নয়
Show Answerউত্তর দেখুন
Answer: (b) — It is reflexive (\( 5 \mid a-a=0 \)), symmetric (\( 5 \mid a-b \Rightarrow 5 \mid b-a \)), and transitive (\( 5 \mid a-b, 5 \mid b-c \Rightarrow 5 \mid a-c \)). R + S + T = equivalence relation. It is not antisymmetric: \( 0 \equiv 5 \) and \( 5 \equiv 0 \) but \( 0 \ne 5 \). It splits integers into 5 equivalence classes.
Answer: (b) — এটি reflexive (\( 5 \mid a-a=0 \)), symmetric (\( 5 \mid a-b \Rightarrow 5 \mid b-a \)) এবং transitive (\( 5 \mid a-b, 5 \mid b-c \Rightarrow 5 \mid a-c \))। R + S + T = equivalence relation। এটি antisymmetric না: \( 0 \equiv 5 \) এবং \( 5 \equiv 0 \) কিন্তু \( 0 \ne 5 \)। এটি integer-দের 5টি equivalence class-এ ভাগ করে।
Q8. How many functions are there from a set with 4 elements to a set with 3 elements? How many of them are injective?
  • (a) 81 total, 0 injective
  • (b) 64 total, 24 injective
  • (c) 81 total, 24 injective
  • (d) 12 total, 0 injective
Q8. 4 element-এর set থেকে 3 element-এর set-এ কতগুলো function আছে? তাদের মধ্যে injective কয়টি?
  • (a) মোট 81, injective 0
  • (b) মোট 64, injective 24
  • (c) মোট 81, injective 24
  • (d) মোট 12, injective 0
Show Answerউত্তর দেখুন
Answer: (a) — Total functions = \( |B|^{|A|} = 3^4 = 81 \). Injective needs all 4 inputs to map to DIFFERENT outputs, but only 3 outputs exist — impossible by the pigeonhole principle. So 0 injective functions.
Answer: (a) — মোট function = \( |B|^{|A|} = 3^4 = 81 \)। Injective হতে 4টি input-এর সবগুলোকে আলাদা output-এ যেতে হবে, কিন্তু output মাত্র 3টি — pigeonhole principle অনুযায়ী অসম্ভব। তাই injective function 0টি।
Q9. How many distinct arrangements can be made from the letters of "BANANA"?
  • (a) 720
  • (b) 120
  • (c) 60
  • (d) 360
Q9. "BANANA" শব্দের letter দিয়ে কতগুলো distinct arrangement করা যায়?
  • (a) 720
  • (b) 120
  • (c) 60
  • (d) 360
Show Answerউত্তর দেখুন
Answer: (c) — BANANA has 6 letters: A×3, N×2, B×1. Arrangements = \( \frac{6!}{3! \, 2!} = \frac{720}{6 \times 2} = 60 \). We divide because swapping identical letters gives the same word.
Answer: (c) — BANANA-তে 6টি letter: A×3, N×2, B×1। Arrangement = \( \frac{6!}{3! \, 2!} = \frac{720}{6 \times 2} = 60 \)। ভাগ করি কারণ একই letter অদল-বদল করলে একই শব্দ পাওয়া যায়।
Q10. (Written) A committee of 4 must be formed from 7 men and 5 women. In how many ways can this be done if the committee must contain at least 2 women?
Q10. (Written) 7 জন পুরুষ আর 5 জন নারী থেকে 4 জনের একটি committee বানাতে হবে। Committee-তে অন্তত 2 জন নারী থাকতে হলে কত ভাবে করা যায়?
Show Answerউত্তর দেখুন
Answer: 285
Split into cases by number of women:
2 women, 2 men: \( \binom{5}{2}\binom{7}{2} = 10 \times 21 = 210 \).
3 women, 1 man: \( \binom{5}{3}\binom{7}{1} = 10 \times 7 = 70 \).
4 women, 0 men: \( \binom{5}{4}\binom{7}{0} = 5 \times 1 = 5 \).
Total: \( 210 + 70 + 5 = 285 \). (Cases are disjoint, so we add — sum rule.)
Answer: 285
নারীর সংখ্যা অনুযায়ী case ভাগ করি:
2 নারী, 2 পুরুষ: \( \binom{5}{2}\binom{7}{2} = 10 \times 21 = 210 \)।
3 নারী, 1 পুরুষ: \( \binom{5}{3}\binom{7}{1} = 10 \times 7 = 70 \)।
4 নারী, 0 পুরুষ: \( \binom{5}{4}\binom{7}{0} = 5 \times 1 = 5 \)।
মোট: \( 210 + 70 + 5 = 285 \)। (Case গুলো আলাদা, তাই যোগ — sum rule।)
Q11. A drawer has socks of 4 different colors. What is the minimum number of socks you must pick (without looking) to guarantee a matching pair?
  • (a) 4
  • (b) 5
  • (c) 8
  • (d) 2
Q11. একটি drawer-এ 4টি ভিন্ন রঙের মোজা আছে। না দেখে অন্তত কয়টি মোজা তুললে একই রঙের একটি জোড়া নিশ্চিত পাওয়া যাবে?
  • (a) 4
  • (b) 5
  • (c) 8
  • (d) 2
Show Answerউত্তর দেখুন
Answer: (b) — Pigeonhole principle: colors are the 4 holes. In the worst case the first 4 socks are all different colors. The 5th sock must repeat some color, giving a pair. So 5.
Answer: (b) — Pigeonhole principle: 4টি রঙ হলো 4টি hole। Worst case-এ প্রথম 4টি মোজা সব ভিন্ন রঙের। 5-তম মোজাটি কোনো একটি রঙ repeat করবেই, তখন জোড়া হবে। তাই 5।
Q12. (Written) Solve the recurrence \( a_n = 4a_{n-1} - 4a_{n-2} \) with \( a_0 = 1 \), \( a_1 = 4 \).
Q12. (Written) Recurrence-টি solve করো: \( a_n = 4a_{n-1} - 4a_{n-2} \), যেখানে \( a_0 = 1 \), \( a_1 = 4 \)।
Show Answerউত্তর দেখুন
Answer: \( a_n = (1 + n) \, 2^n \)
Characteristic equation: \( r^2 - 4r + 4 = 0 \Rightarrow (r-2)^2 = 0 \). Repeated root \( r = 2 \).
Repeated root form: \( a_n = (\alpha + \beta n) 2^n \).
\( n=0: \alpha = 1 \). \( n=1: (\alpha + \beta) \cdot 2 = 4 \Rightarrow \alpha + \beta = 2 \Rightarrow \beta = 1 \).
So \( a_n = (1+n)2^n \). Check \( a_2 \): recurrence: \( 4(4) - 4(1) = 12 \); formula: \( 3 \times 4 = 12 \). ✓
Common mistake: using \( \alpha \, 2^n + \beta \, 2^n \) — that collapses to one constant and cannot fit both initial conditions. The extra factor n is required.
Answer: \( a_n = (1 + n) \, 2^n \)
Characteristic equation: \( r^2 - 4r + 4 = 0 \Rightarrow (r-2)^2 = 0 \)। Repeated root \( r = 2 \)।
Repeated root-এর form: \( a_n = (\alpha + \beta n) 2^n \)।
\( n=0: \alpha = 1 \)। \( n=1: (\alpha + \beta) \cdot 2 = 4 \Rightarrow \alpha + \beta = 2 \Rightarrow \beta = 1 \)।
তাই \( a_n = (1+n)2^n \)। \( a_2 \) check: recurrence: \( 4(4) - 4(1) = 12 \); formula: \( 3 \times 4 = 12 \)। ✓
Common mistake: \( \alpha \, 2^n + \beta \, 2^n \) লেখা — এটা একটাই constant হয়ে যায়, দুটো initial condition মেলানো যায় না। বাড়তি n factor-টা লাগবেই।
Q13. A simple graph has 7 vertices, each of degree 4. How many edges does it have?
  • (a) 28
  • (b) 14
  • (c) 21
  • (d) 11
Q13. একটি simple graph-এ 7টি vertex, প্রতিটির degree 4। Graph-টিতে কয়টি edge?
  • (a) 28
  • (b) 14
  • (c) 21
  • (d) 11
Show Answerউত্তর দেখুন
Answer: (b) — Handshaking lemma: \( \sum \deg(v) = 2|E| \). Sum = \( 7 \times 4 = 28 \), so \( |E| = 28 / 2 = 14 \). Forgetting to divide by 2 gives the trap answer (a).
Answer: (b) — Handshaking lemma: \( \sum \deg(v) = 2|E| \)। যোগফল = \( 7 \times 4 = 28 \), তাই \( |E| = 28 / 2 = 14 \)। 2 দিয়ে ভাগ করতে ভুলে গেলে trap answer (a) আসে।
Q14. (Written) A connected graph has vertices with degrees 2, 2, 4, 4, 3, 3. (i) Does it have an Euler circuit? An Euler path? (ii) If a spanning tree is built from this graph, how many edges will the tree have, and how many edges must be deleted?
Q14. (Written) একটি connected graph-এর vertex-দের degree 2, 2, 4, 4, 3, 3। (i) এতে কি Euler circuit আছে? Euler path? (ii) এই graph থেকে spanning tree বানালে tree-তে কয়টি edge থাকবে, আর কয়টি edge মুছতে হবে?
Show Answerউত্তর দেখুন
Answer:
(i) Odd-degree vertices: the two vertices of degree 3 — exactly 2 odd vertices. So NO Euler circuit (that needs 0 odd), but YES an Euler path exists, starting at one degree-3 vertex and ending at the other.
(ii) Total edges by handshaking: \( (2+2+4+4+3+3)/2 = 18/2 = 9 \). A spanning tree on \( n = 6 \) vertices has \( n - 1 = 5 \) edges. Edges to delete: \( 9 - 5 = 4 \).
Answer:
(i) Odd-degree vertex: degree 3-এর দুটি vertex — ঠিক 2টি odd vertex। তাই Euler circuit নেই (তার জন্য 0টি odd লাগে), কিন্তু Euler path আছে — এক degree-3 vertex-এ শুরু, অন্যটিতে শেষ।
(ii) Handshaking দিয়ে মোট edge: \( (2+2+4+4+3+3)/2 = 18/2 = 9 \)। \( n = 6 \) vertex-এর spanning tree-তে \( n - 1 = 5 \) টি edge। মুছতে হবে: \( 9 - 5 = 4 \) টি edge।
Q15. (Written) (i) Use the Euclidean algorithm to find \( \gcd(1071, 462) \), and compute \( \text{lcm}(1071, 462) \). (ii) Find the remainder when \( 7^{2026} \) is divided by 10 (i.e., its last digit).
Q15. (Written) (i) Euclidean algorithm ব্যবহার করে \( \gcd(1071, 462) \) বের করো, এবং \( \text{lcm}(1071, 462) \) হিসাব করো। (ii) \( 7^{2026} \)-কে 10 দিয়ে ভাগ করলে remainder কত (অর্থাৎ last digit)?
Show Answerউত্তর দেখুন
Answer:
(i) Euclidean algorithm:
\( 1071 = 2 \times 462 + 147 \)
\( 462 = 3 \times 147 + 21 \)
\( 147 = 7 \times 21 + 0 \)
So \( \gcd = 21 \). Then \( \text{lcm} = \frac{1071 \times 462}{21} = 1071 \times 22 = 23562 \).
(ii) Powers of 7 mod 10 cycle: \( 7^1 = 7, 7^2 = 9, 7^3 = 3, 7^4 = 1 \), then repeat (cycle length 4).
\( 2026 = 4 \times 506 + 2 \), so \( 7^{2026} \equiv 7^2 \equiv 9 \pmod{10} \).
The remainder (last digit) is 9.
Answer:
(i) Euclidean algorithm:
\( 1071 = 2 \times 462 + 147 \)
\( 462 = 3 \times 147 + 21 \)
\( 147 = 7 \times 21 + 0 \)
তাই \( \gcd = 21 \)। এরপর \( \text{lcm} = \frac{1071 \times 462}{21} = 1071 \times 22 = 23562 \)।
(ii) 7-এর power mod 10-এর cycle: \( 7^1 = 7, 7^2 = 9, 7^3 = 3, 7^4 = 1 \), তারপর repeat (cycle length 4)।
\( 2026 = 4 \times 506 + 2 \), তাই \( 7^{2026} \equiv 7^2 \equiv 9 \pmod{10} \)।
Remainder (last digit) হলো 9
Q16. (Real exam style) How many integers from 1 to 500 are divisible by NONE of 4, 6, and 15?
  • (a) 316
  • (b) 184
  • (c) 324
  • (d) 259
Q16. (Real exam style) 1 থেকে 500-এর মধ্যে কতগুলো integer 4, 6 এবং 15-এর কোনোটা দিয়েই divisible নয়?
  • (a) 316
  • (b) 184
  • (c) 324
  • (d) 259
Show Answerউত্তর দেখুন
Answer: (a)
Careful: for the overlaps use the LCM, not the product. \( \text{lcm}(4,6) = 12 \) (NOT 24!), \( \text{lcm}(4,15) = 60 \), \( \text{lcm}(6,15) = 30 \), \( \text{lcm}(4,6,15) = 60 \).
Singles: \( \lfloor 500/4 \rfloor = 125 \), \( \lfloor 500/6 \rfloor = 83 \), \( \lfloor 500/15 \rfloor = 33 \).
Pairs: \( \lfloor 500/12 \rfloor = 41 \), \( \lfloor 500/60 \rfloor = 8 \), \( \lfloor 500/30 \rfloor = 16 \).
Triple: \( \lfloor 500/60 \rfloor = 8 \).
Divisible by at least one: \( 125 + 83 + 33 - 41 - 8 - 16 + 8 = 184 \).
Divisible by none: \( 500 - 184 = \mathbf{316} \). (Option (b) is the trap — 184 counts the divisible ones, but the question asks for NONE.)
Answer: (a)
সাবধান: overlap-এর জন্য LCM ব্যবহার করো, গুণফল নয়। \( \text{lcm}(4,6) = 12 \) (24 নয়!), \( \text{lcm}(4,15) = 60 \), \( \text{lcm}(6,15) = 30 \), \( \text{lcm}(4,6,15) = 60 \)।
Single: \( \lfloor 500/4 \rfloor = 125 \), \( \lfloor 500/6 \rfloor = 83 \), \( \lfloor 500/15 \rfloor = 33 \)।
Pair: \( \lfloor 500/12 \rfloor = 41 \), \( \lfloor 500/60 \rfloor = 8 \), \( \lfloor 500/30 \rfloor = 16 \)।
Triple: \( \lfloor 500/60 \rfloor = 8 \)।
অন্তত একটি দিয়ে divisible: \( 125 + 83 + 33 - 41 - 8 - 16 + 8 = 184 \)।
কোনোটা দিয়েই divisible না: \( 500 - 184 = \mathbf{316} \)। (Option (b) হলো trap — 184 হলো divisible-দের সংখ্যা, কিন্তু প্রশ্ন চেয়েছে NONE।)
Q17. (Real exam style — proof) (i) Every student's name gives an initial pair (first letter of first name, first letter of last name), each from the 26 English letters. What is the minimum number of students seated in a hall that GUARANTEES at least two students share the same initial pair? (ii) Prove by strong induction that every amount \( n \ge 12 \) taka can be paid using only 4-taka and 5-taka notes.
Q17. (Real exam style — proof) (i) প্রতিটি student-এর নাম থেকে একটি initial pair পাওয়া যায় (first name-এর প্রথম letter, last name-এর প্রথম letter), প্রতিটি 26টি English letter থেকে। Hall-এ অন্তত কত জন student বসালে নিশ্চিত (GUARANTEE) হবে যে অন্তত দুই জনের initial pair একই? (ii) Strong induction দিয়ে প্রমাণ করো যে প্রতিটি amount \( n \ge 12 \) taka শুধু 4-taka আর 5-taka note দিয়ে দেওয়া যায়।
Show Answerউত্তর দেখুন
Answer:
(i) Pigeonhole principle. The holes are the possible initial pairs: \( 26 \times 26 = 676 \). With 676 students, the worst case is that ALL pairs are different — no guarantee yet. One more student must repeat some pair. Minimum: \( 676 + 1 = \mathbf{677} \) students. (BUET asked this seating-guarantee style in April 2019.)
(ii) Strong induction on \( n \).
Base cases (one full block of 4 numbers): \( 12 = 4+4+4 \), \( 13 = 4+4+5 \), \( 14 = 4+5+5 \), \( 15 = 5+5+5 \).
Inductive step: take any \( n \ge 16 \). Then \( n - 4 \ge 12 \), so by the strong induction hypothesis \( n-4 \) taka can be paid. Add one more 4-taka note — that pays \( n \) taka.
So every \( n \ge 12 \) taka can be paid. ✓
Answer:
(i) Pigeonhole principle। Hole হলো সম্ভাব্য initial pair: \( 26 \times 26 = 676 \) টি। 676 জন student হলে worst case-এ সবার pair আলাদা হতে পারে — তখনো guarantee নেই। আর একজন student এলে কোনো একটি pair repeat হবেই। Minimum: \( 676 + 1 = \mathbf{677} \) জন। (BUET April 2019-এ এই seating-guarantee ধরনটাই জিজ্ঞেস করেছে।)
(ii) \( n \)-এর উপর strong induction।
Base case (4টি সংখ্যার একটি পুরো block): \( 12 = 4+4+4 \), \( 13 = 4+4+5 \), \( 14 = 4+5+5 \), \( 15 = 5+5+5 \)।
Inductive step: যেকোনো \( n \ge 16 \) নাও। তাহলে \( n - 4 \ge 12 \), তাই strong induction hypothesis অনুযায়ী \( n-4 \) taka দেওয়া যায়। আর একটি 4-taka note যোগ করো — \( n \) taka দেওয়া হয়ে গেল।
তাই প্রতিটি \( n \ge 12 \) taka দেওয়া যায়। ✓