The problem in brief
This is the written theory paper of the June 2025 training camp of the Romanian national AI team. It has 17 short problems that sweep the whole classical AI syllabus: data preparation (scaling, outliers, encoding, regularisation), probabilistic and tree classifiers, k-means, game search (minimax and alpha-beta), heuristic search (A*), logic and resolution, constraint satisfaction, approximate Q-learning, evaluation metrics, kernels and recommender systems. Each problem is a small hand computation followed by a "why" question. The paper is in Romanian; the answers below are our own derivations, and every number was rechecked with a short Python script (solution.py).
How you are scored
The paper is marked by hand. The published PDF gives no point scale and no answer key, so there is no threshold to compare with. What a marker looks for is visible in the wording: a correct number and a justification (several sub-questions say "Argumentați", "justify", and Problem 10 explicitly gives no credit to a proof that does not use resolution). The corrections below therefore always show the reasoning, not just the result.
Question by question
Problem 1: scaling and outliers
The table has a monthly income in euros (1 000 to 12 000) and a satisfaction score from 0 to 10.
a) A distance such as adds the two columns as if they had the same unit. A difference of 1 000 euros then counts a million times more than a difference of 1 point of satisfaction, so k-NN effectively ignores the score. Normalising puts both columns on a comparable scale, for example min-max scaling or standardisation .
b) Sorted incomes: . With the "median of each half" rule, and , so and the fences are
12 000 is the only outlier. Other quartile conventions move the fences a little (NumPy's linear interpolation gives , and an upper fence of 8 437.5), but the verdict does not change.
c) Robust scaling, . Standard scaling uses the mean and the standard deviation, which the 12 000 inflates: the mean jumps to 4 650 and the five ordinary users get squeezed together. The median and the IQR barely notice one extreme value.
Problem 2: encoding categories
a) CategorieAliment (dairy, meat, vegetables) is nominal: there is no natural order. Use one-hot encoding (three 0/1 columns). Mapping the categories to 0, 1, 2 would invent an order and distances (meat "between" dairy and vegetables) that a model would take seriously. ConținutGrăsime (low, medium, high) is ordinal, so ordinal encoding low = 0, medium = 1, high = 2 keeps the information that high > medium > low in a single column.
b) Min-max with and , so a range of 10:
| ID | price | scaled |
|---|---|---|
| 1 | 5.4 | 0.19 |
| 2 | 13.5 | 1.00 |
| 3 | 3.8 | 0.03 |
| 4 | 11.0 | 0.75 |
| 5 | 3.5 | 0.00 |
Problem 3: L1 or L2?
The L2 penalty has gradient , which shrinks every coefficient proportionally and never quite reaches zero. The L1 penalty pushes every nonzero coefficient with the same force , so small coefficients hit exactly zero.
- a) many correlated features, shrink them without removing them: L2 (Ridge);
- b) remove irrelevant features, automatic selection: L1 (Lasso);
- c) only a small subset of features matters (a sparse truth): L1 (Lasso);
- d) a penalty spread evenly over all coefficients: L2 (Ridge).
Problem 4: Naive Bayes for Josh
Josh is absent on days 1 to 4 and present on days 5 to 10.
a) Counting (maximum likelihood estimation):
| (4 days) | (6 days) | |
|---|---|---|
| 0.4 | 0.6 | |
| 0/4 = 0 | 3/6 = 1/2 | |
| 0/4 = 0 | 2/6 = 1/3 | |
| 2/4 = 1/2 | 4/6 = 2/3 |
(The probabilities for value 0 are the complements.)
b) For :
Absent is more likely: after normalising, .
c) With and values per sensor, every count gets and every denominator :
| 1/6 | 4/8 = 1/2 | |
| 1/6 | 3/8 | |
| 3/6 = 1/2 | 5/8 |
The main change is that no probability is 0 any more. Under MLE, a single pressure or motion reading would force , whatever the other sensors say, which is far too confident after only 4 absent days. For the new observation, against : the decision is still absent, but less clearly (). Smoothing the prior as well, and , gives the same decision.
Problem 5: a decision tree for the exam
The six students: 4 passed, 2 failed.
a) bits.
b) For each value of Parcurs: "small" has 1 pass and 1 fail (entropy 1), "medium" also (entropy 1), "large" has 2 passes (entropy 0). Each value covers a third of the students:
c) To build the tree, compare with the other attribute. The students who studied all passed (entropy 0). Those who did not have 2 fails and 1 pass (entropy 0.92). So . The information gains are for Parcurs and for Învățat, so the root tests "studied?":
- studied = yes: passed (3 of 3);
- studied = no: test Parcurs: small gives failed, medium gives failed, large gives passed.
Every leaf is pure: the tree fits the six students exactly with 4 leaves.
Problem 6: one k-means step with Manhattan distance
Distances to and :
| point | to | to | cluster |
|---|---|---|---|
| A(1,2) | 1 | 14 | 1 |
| B(2,1) | 1 | 14 | 1 |
| C(4,5) | 5 | 8 | 1 |
| D(7,8) | 11 | 2 | 2 |
| E(8,8) | 12 | 1 | 2 |
| F(9,9) | 14 | 1 | 2 |
b) New centroids (coordinate-wise means):
(With the Manhattan distance, the centre that minimises the sum of distances would be the coordinate-wise median, as in k-medians. The statement asks for the mean, so we use the mean.)
Problem 7: minimax and alpha-beta
a) Each MAX node on the third level takes the largest of its three leaves, each MIN node the smallest of those, and the root the largest MIN value:
- MIN 1: ;
- MIN 2: ;
- MIN 3: .
The root is worth 7. MAX plays the third branch, MIN answers with its first child (worth 7, ties broken to the left), and the game ends on the leaf 7 (the middle leaf of 3, 7, 2).
b) Yes, cuts happen. Going left to right and cutting when at a MAX node or at a MIN node:

- Under MIN 1, after the first MAX child, . The second MAX child sees 2, then 7: since , MIN will never let play reach it, and leaf 9 is pruned (beta cut).
- Third MAX child of MIN 1: 3, then 5, and : leaf 7 is pruned (beta cut, on equality).
- At the root, . Under MIN 2, goes to 10, then 6. The third MAX child sees 8, and : leaves 9 and 2 are pruned.
- Now . Under MIN 3, the first MAX child is worth 7, so . The second sees 7, and : leaves 6 and 5 are pruned.
- The third sees 9, and : leaves 8 and 9 are pruned.
All five are beta cuts (at MAX nodes, because the MIN parent already has something better). There is no alpha cut: the MIN values come in increasing order (5, 6, 7), so no MIN node ever falls below the current . Alpha-beta evaluates 19 leaves instead of 27 and still returns 7. If your course only cuts on strict inequality, cuts 2 and 4 disappear and 22 leaves are evaluated.
c) If MAX takes control of a MIN node, that node gives MAX the largest of its children, minus the cost: for MIN 1, for MIN 2 and for MIN 3. Forcing MIN 2 to enter the subtree worth 10 gives 8 > 7, so using the ability is optimal, on the second branch. (Paying for it on the third branch would only tie with the free value 7.)
Problem 8: A* and heuristics
Edges: G-F 5, F-D 3, G-D 9, G-E 2, E-D 8, D-B 5, B-A 1, D-C 3, C-B 1, C-A 4. True distances to G (Dijkstra from G): , , , , , , .
a) Admissible means for every state. The given values all satisfy it (, , , , ), so is admissible if and only if .
Consistent means for every edge, in both directions (the graph is undirected), with . The edges that do not touch B are fine (for example ). The edges at B give:
- B-A, cost 1: , so ;
- B-C, cost 1: , so ;
- B-D, cost 5: , so .
So is consistent if and only if . As expected, it is a narrower window than admissibility, since consistency implies admissibility.
b) Careful: as a returned path, A → C → B → D → E → G is impossible for graph-search A*, whatever the heuristic. A is expanded first and puts B in the frontier with ; later, reaching B through C would cost , which never replaces the better parent A. The question therefore makes sense as the order of expansion. We need, step by step:
- after A: ;
- after C (D now has ): ;
- B lowers D to , then D is expanded and puts F (), E () and G () in the frontier: we need and ;
- finally G (15) must come out before F: .
satisfies all of these, and a simulation confirms the expansion order A, C, B, D, E, G. This is not admissible (), and it has to be inadmissible: E is expanded before F although F is on the optimal route. A* then returns the path A → B → D → G of cost 15 instead of the optimal 13, which illustrates what an overestimating heuristic does.
c) Yes: . It is admissible because each of the two is at most , so their maximum is too. It dominates both ( and everywhere), and a dominating admissible heuristic never makes A* expand more nodes (for consistent heuristics, every node expanded with is also expanded with and with ). On our graph, with from a) and "smallest edge leaving " (1 for A, 1 for B, 1 for C, 3 for D, 2 for E, 3 for F, 0 for G), takes almost everywhere but improves E to 2. By contrast, is not a safe choice: it can overestimate.
Problem 9: propositional resolution
a) Let = "PROG1 is correct" and = "PROG1 produces conforming results". The premises are and , and the conclusion is .
b) Put everything in CNF and add the negation of the conclusion:
Resolving (1) with (3) on gives (4) . Resolving (4) with (2) gives the empty clause . The premises plus are contradictory, so follows: this is modus ponens, proved by refutation.
Problem 10: first-order resolution
a) With = "the head of is bowed" and = "the head of is cut by the sword", the proverb "a bowed head is not cut by the sword" becomes
The goal is .
b) Clauses: (1) , (2) , (3) the negated goal . Resolve (1) and (3) with the unifier , which gives (4) . Resolve (4) with (2), which gives . Hence Marcel's head was not bowed. (The logic is the contrapositive: no bowed head is cut, Marcel's head was cut, so it was not bowed.)
Problem 11: arc consistency (AC-3)
Domains , , . Constraints , , .
a) An arc is consistent if every value of has a supporting value of . Checking the six arcs:
- : no ( has no smaller );
- : no ( would need );
- : no ( needs );
- : no ( needs );
- : no ( needs );
- : yes, since every has .
So exactly one arc, , is already arc-consistent.
b) The queue starts with all arcs, in both directions: 3 binary constraints give 6 arcs. An arc is put back into the queue only when a value is deleted from the domain of . A domain of size can lose at most values, so each arc enters the queue at most times, where is the largest domain size: here (the domain of ). This is what gives AC-3 its running time for constraints.
c) Running AC-3:
- with : ;
- : ;
- with : ;
- now holds for every pair (), and all the other arcs are consistent.
Final domains: , , . Note that arc consistency does not solve the problem by itself: the real solutions are only the three triples for .
Problem 12: scheduling as a CSP
a) One variable per exam, (Math), (CS) and (Physics). Each takes a value that is a (room, slot) pair, with domain , 6 values. Write and for the two parts of a value.
b) The constraints:
- (shared students);
- ;
- a room hosts at most one exam per slot: , and as pairs (all-different on the (room, slot) values).
c) Backtracking in the order , values in lexicographic order:
- ;
- : is rejected (same pair, and same slot as M); is accepted;
- : is rejected (same room as C); is accepted (it differs from M's pair, and from C's room).
Solution: Math in S1 at T1, CS in S1 at T2, Physics in S2 at T1. No backtrack was even needed.
Problem 13: approximate Q-learning for Pacman
In the figure, Pacman sits between two ghosts (one directly to its left, one directly to its right), with a food pellet directly above. The wall below makes "down" impossible. In the current state, (two adjacent ghosts) and (one adjacent pellet).
a) The features for each action:
| action | (ghosts hit) | (ghosts adjacent after) | (food eaten) | ||
|---|---|---|---|---|---|
| left | 1 | 0 | 3 | 0 | 1 |
| right | 1 | 0 | 3 | 0 | 1 |
| up | 0 | 0 | 2 | 1 | 3 |
| stay | 0 | 2 | 4 | 0 | 1 |
After "left", Pacman is on the ghost (distance 0, counted in ), and the other ghost is now 2 cells away, so . After "up", both ghosts are diagonal, at Manhattan distance 2, so .
b) With : , , . "Up" is the best action.
c) In (the pellet's cell), no ghost and no pellet is adjacent, so . "Down" goes back between the ghosts: , , so . "Stay" gives . Then
d) The error is , and the features of "up" are , :
The prediction was too optimistic, so both weights move in the direction that lowers . The food weight drops a lot (Pacman had overrated food), and the ghost weight becomes more negative (ghosts now look more dangerous).
Problem 14: metrics from a confusion matrix
Rows are true classes, columns predictions. Column sums: 46, 48, 56. Row sums: 50 each.
a) Precision: , , .
b) Recalls are , and , so
c) Micro-averaged recall pools all the classes: . (In single-label classification, micro recall always equals accuracy.)
d) If missing a class-C case is very costly (a rare, serious disease), maximise the recall of class C (sensitivity), possibly under a minimum-precision constraint, or use with . Ways to get there: lower the decision threshold for C (predict C as soon as exceeds, say, 0.2), weight class C more in the loss (cost-sensitive learning), or rebalance the training data (oversampling C, SMOTE). Here 11 of the 50 B cases are predicted as C and 8 of the 50 C cases as B, so the B/C boundary is where to work.
Problem 15: a kernel and a non-kernel
a) There are finitely many possible 16×16 patches: of them. Index them , and define by if patch appears somewhere in , and 0 otherwise. Then
So is an inner product in with , which makes it a kernel. The "count once" rule in the statement is exactly what makes the coordinates 0/1. An image smaller than 16×16 simply maps to the zero vector.
b) Take three images:
- : a 16×16 all-black square (patch );
- : a 16×16 all-white square (patch );
- : a 16×32 image, black on the left half and white on the right half, which contains both and .
and share no patch, and each image shares a patch with itself, so
Then , so is not positive semidefinite (its eigenvalues are , and ), and is not a kernel. The intuition: "share at least one patch" is not transitive. and but , and no inner product of feature vectors can behave like that with these 0/1 values.
Problem 16: user-based collaborative filtering
Means over each user's own ratings: , , .
a)
- share items 1 and 4. The deviations are and , so .
- share items 1, 2 and 4. The deviations are and , so .
is the most similar to (perfect agreement), while has opposite tastes.
b)
The negative similarity is used constructively: loved item 3, and since is an "anti-", that pulls the prediction below 's mean. (If you compute each mean only over the co-rated items, you get slightly different numbers. Say which convention you use.)
c) A new user has no ratings, so no co-rated items, so every similarity is undefined and the formula collapses (cold start). A content-based fallback: describe each item by a feature vector (for example genres as 0/1). Ask the new user for a few liked genres at sign-up, or use the first items they click, to build a profile vector (the average of the liked items' vectors). Then recommend the items with the highest . It needs no other user, so it works from the first interaction, and you can switch progressively to collaborative filtering as ratings accumulate (a hybrid system).
Problem 17: the PQ kernel is an inner product
Index the coordinates of a feature vector by the pairs , so the vector has coordinates, and set
(For a permutation there are no ties, so the sign is never 0.) Then
Each term is exactly when (a concordant pair) and exactly when it is (a discordant pair). The sum is therefore , an explicit inner product, so is a kernel. (We checked the identity on random permutations.) Dividing by gives Kendall's , which shows that Kendall's correlation is a normalised kernel. For rankings with ties, the same gives 0 on tied pairs, which matches the definitions of and .
What to remember
- Scale-sensitive models need scaling, and outliers decide which scaler. With distances (k-NN, k-means, SVM), unscaled columns silently drop out. With an outlier, use the median and the IQR, not the mean and the standard deviation.
- Search questions are bookkeeping: write the frontier. For alpha-beta, note and at each node and check "" or "". For A*, write at each step. Before designing a heuristic, ask whether the requested behaviour is even reachable: in Problem 8, no heuristic can make A* return a path through a worse parent.
- Admissible means never overestimating; consistent is a triangle inequality on every edge. The max of admissible heuristics is admissible and dominates both.
- To prove a kernel, exhibit the feature map; to disprove it, exhibit a Gram matrix with . Three well-chosen points usually suffice, and a non-transitive similarity is the classic counterexample.
- Approximate Q-learning is linear regression on the TD target. , then : each weight moves in proportion to how active its feature was.