WIKIPEFIA

Эта статья недоступна на вашем языке. Показана версия на EN.

Статья предмета20 мин чтения

Практические задачи

Practice Problems

Theory without practice is incomplete. This article provides interactive problems covering logic, sets, combinatorics, and graphs — test your understanding with quizzes, code challenges, and worked examples.

Section 1: Logic

Quiz — Truth Tables

■ Викторина3 вопросов

Q1.What is the truth value of (T → F) ∧ (F → T)?

Q2.Which logical connective has this truth table: TT→T, TF→T, FT→F, FF→T?

Q3.De Morgan's Law: ¬(p ∧ q) is equivalent to...

0/3 отвечено

Practice — Boolean Simplification

Simplify the following boolean expression using logical equivalences:

¬(¬pq)(pq)\lnot(\lnot p \lor q) \lor (p \land q)

Section 2: Sets and Counting

Quiz — Set Operations

■ Викторина3 вопросов

Q1.If A = {1,2,3,4} and B = {3,4,5,6}, what is |A ∪ B|?

Q2.How many subsets does a set with 5 elements have?

Q3.C(10, 3) = ?

0/3 отвечено

Code Challenge — Powerset Generator

Write a function that generates the powerset (set of all subsets) of a given set.

▶ Песочницаpython
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Редактируемо — измените код выше для экспериментов

Section 3: Combinatorics

The Birthday Problem

What's the probability that in a room of nn people, at least two share a birthday?

P(at least one match)=1365!365n(365n)!P(\text{at least one match}) = 1 - \frac{365!}{365^n \cdot (365-n)!}
▶ Песочницаpython
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Редактируемо — измените код выше для экспериментов

Section 4: Graphs

Quiz — Graph Properties

■ Викторина3 вопросов

Q1.A tree with 10 vertices has how many edges?

Q2.What is the maximum number of edges in a simple undirected graph with 6 vertices?

Q3.Which traversal uses a queue?

0/3 отвечено

Code Challenge — Shortest Path

Implement Dijkstra's algorithm for finding the shortest path in a weighted graph.

▶ Песочницаpython
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Редактируемо — измените код выше для экспериментов

Summary

Key takeaways from this practice session:

  1. Logic: Master De Morgan's laws and truth tables — they're the basis of all conditional reasoning
  2. Counting: The multiplication principle, permutations, and combinations appear in algorithm analysis constantly
  3. Graphs: Know both BFS and DFS, understand adjacency representations, and practice shortest-path algorithms
  4. Practice > Theory: The only way to get better is to solve more problems